microsoft / vscode-remote-release

Visual Studio Code Remote Development: Open any folder in WSL, in a Docker container, or on a remote machine using SSH and take advantage of VS Code's full feature set.
https://aka.ms/vscode-remote
Other
3.62k stars 281 forks source link

Remote-SSH: Local server download fails in 1.85 #9246

Closed drisspg closed 9 months ago

drisspg commented 10 months ago

Is there an existing issue for this bug?

Required Troubleshooting Steps

Connect Locally

It connects successfully

->

No response

Expected Behavior

Connects succsefully

Steps To Reproduce

I recently updated vscode-insider versions, was working prior to update

Remote-SSH Log

[12:04:33.468] Terminating local server
[12:04:33.470] Resolver error: Error: XHR failed
    at k.onerror (vscode-file://vscode-app/private/var/folders/g1/cvs2rnpx60qc3b4_x72xvxlr0000gn/T/AppTranslocation/1EDA0CA8-65F0-4A71-83AE-D707E1E03A65/d/Visual%20Studio%20Code%20-%20Insiders.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:95:2027)
[12:04:33.474] TELEMETRY: {"eventName":"resolver","properties":{"osReleaseId":"","arch":"","askedPw":"0","askedPassphrase":"0","asked2fa":"0","askedHostKey":"0","remoteInConfigFile":"1","gotUnrecognizedPrompt":"0","dynamicForwarding":"1","localServer":"1","didLocalDownload":"0","installUnpackCode":"0","outcome":"failure","reason":"Unknown","exitCodeLabel":""},"measures":{"resolveAttempts":1,"isExecServer":0,"timing.totalResolveTime":7217,"timing.preSshTime":27,"timing.establishSshTime":6250}}
[12:04:33.475] ------

[12:04:33.481] Local server exit: 15

Anything else?

Same error when running without local_server mode

[12:06:01.219] Downloading VS Code server locally...
[12:06:01.310] Resolver error: Error: XHR failed
    at k.onerror (vscode-file://vscode-app/private/var/folders/g1/cvs2rnpx60qc3b4_x72xvxlr0000gn/T/AppTranslocation/1EDA0CA8-65F0-4A71-83AE-D707E1E03A65/d/Visual%20Studio%20Code%20-%20Insiders.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:95:2027)
[12:06:01.311] TELEMETRY: {"eventName":"resolver","properties":{"osReleaseId":"","arch":"","askedPw":"0","askedPassphrase":"0","asked2fa":"0","askedHostKey":"0","remoteInConfigFile":"1","gotUnrecognizedPrompt":"0","dynamicForwarding":"1","localServer":"0","didLocalDownload":"0","installUnpackCode":"0","outcome":"failure","reason":"Unknown","exitCodeLabel":""},"measures":{"resolveAttempts":1,"isExecServer":0,"timing.totalResolveTime":8002,"timing.preSshTime":1670,"timing.establishSshTime":6229,"timing.scriptTime":6332}}
[12:06:01.312] ------
drisspg commented 10 months ago

I am trying to manual install the server with

wget https://update.code.visualstudio.com/commit:b3b84b5239037a2f0ef8499306df9a3bacda4105/server-linux-x64/stable

And I am getting a 404 not found

roblourens commented 10 months ago

That's an insiders commit, but the url says /stable, where did you get that from, is it in a log?

Can you check the "Extension Host" or "Window" log for network-related errors?

drisspg commented 10 months ago

Sorry that is an old wget command I have tried in the past, what is the correct path?

In Extension Host I see

2023-11-29 09:58:46.520 [error] Error: XHR failed
    at k.onerror (vscode-file://vscode-app/Applications/Visual%20Studio%20Code%20-%20Insiders.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:95:2027) _workbench.downloadResource undefined
2023-11-29 09:58:46.526 [error] [resolveAuthority(ssh-remote,1)][5055ms] returned an error XHR failed
2023-11-29 09:58:46.610 [error] CodeExpectedError: ENOPRO: No file system provider found for resource
roblourens commented 10 months ago

The correct one would be /insider

justin39 commented 10 months ago

Seeing the same issue on the latest Insiders build:

[17:27:36.505] Resolver error: Error: XHR failed
    at k.onerror (vscode-file://vscode-app/c:/Users/justinw/AppData/Local/Programs/Microsoft%20VS%20Code%20Insiders/resources/app/out/vs/workbench/workbench.desktop.main.js:95:2027)

Insiders build version:

Version: 1.85.0-insider (user setup)
Commit: 8762127fc97b8aaae5f3a0dd6a6d853d9a1b7574
Date: 2023-11-29T17:38:23.440Z
Electron: 25.9.6
ElectronBuildId: 25427645
Chromium: 114.0.5735.289
Node.js: 18.15.0
V8: 11.4.183.29-electron.0
OS: Windows_NT x64 10.0.19044

The version of the "Remote - SSH" extension doesn't seem to matter between pre-release/stable/older versions. The workaround noted above does work (i.e. wget https://update.code.visualstudio.com/commit:8762127fc97b8aaae5f3a0dd6a6d853d9a1b7574/server-linux-x64/insider).

My users settings set remote.SSH.useExecServer: false as a workaround to a prior SSH issue with VS Code, but flipping to true also seems to have no impact other than changing the failing artifact from vscode-server.tar.gz to vscode-cli-8762127fc97b8aaae5f3a0dd6a6d853d9a1b7574.tar.gz.

roblourens commented 9 months ago

Do you have anything like a corporate proxy configured? Do you have the http.proxy setting set?

justin39 commented 9 months ago

Do you have anything like a corporate proxy configured? Do you have the http.proxy setting set?

Yes, this is behind a corporate proxy - http.proxy is not set

AxisRay commented 9 months ago

Same error

版本: 1.85.0-insider (Universal)
提交: c46c2f120b96f1d538333b263e42d1f133a200f0
日期: 2023-12-05T09:55:05.986Z
Electron: 25.9.7
ElectronBuildId: 25551756
Chromium: 114.0.5735.289
Node.js: 18.15.0
V8: 11.4.183.29-electron.0
OS: Darwin arm64 23.1.0
Remote-SSH: v0.108.2023112915
[21:42:43.442] Got request to download on client for {"artifact":"cli-alpine-x64","destPath":"/root/.vscode-server-insiders/vscode-cli-c46c2f120b96f1d538333b263e42d1f133a200f0.tar.gz"}
[21:42:43.442] Downloading VS Code server locally...
[21:42:43.923] Terminating local server
[21:42:43.925] Resolver error: Error: XHR failed
    at k.onerror (vscode-file://vscode-app/Applications/Visual%20Studio%20Code%20-%20Insiders.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:95:2027)
[21:42:43.932] ------

image

Access to XMLHttpRequest at 'https://vscode.download.prss.microsoft.com/dbazure/download/insider/c46c2f1…/vscode_cli_alpine_x64_cli.tar.gz' (redirected from 'https://update.code.visualstudio.com/commit:c46c2f1…/cli-alpine-x64/insider') from origin 'vscode-file://vscode-app' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
roblourens commented 9 months ago

Oh, yes I forgot about this: https://code.visualstudio.com/updates/v1_85#_new-cdn

There is a new CDN that we will download from, and your sysadmin may have to allow that new hostname

AxisRay commented 9 months ago

Oh, yes I forgot about this: https://code.visualstudio.com/updates/v1_85#_new-cdn

There is a new CDN that we will download from, and your sysadmin may have to allow that new hostname

well,it's YOUR sysadmin not MY sysadmin.

the CORS policy: 'Access-Control-Allow-Origin' should be configured correctly at the CDN side.

EISHKARAN commented 9 months ago

I have even facing the same issue till last evening I was able to connect to the server and then it got disconnected after that when I tried its giving me XHR failed.
Tried deleting the whole vscode insiders by deleting it's dot files and installing it again but didn't help.

[13:10:31.195] Got request to download on client for {"artifact":"cli-alpine-x64","destPath":"/shared/home/v_eishkaran_singh/.vscode-server-insiders/vscode-cli-ab0520decb7284b2b2a9bbe3ababea57ac83c86b.tar.gz"} [13:10:31.196] Downloading VS Code server locally... [13:10:32.165] Terminating local server [13:10:32.166] Resolver error: Error: XHR failed at k.onerror (vscode-file://vscode-app/Applications/Visual%20Studio%20Code%20-%20Insiders.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:95:2027) [13:10:32.181] Local server exit: 15 [13:10:32.206] ------ Help out how to resolve it from the user end cause the server can't be accessed in my case. @roblourens

roblourens commented 9 months ago

@AxisRay I'm referring to the fact that some configurations only allow connections to a fixed set of allowed hosts, and I'm assuming that is part of the issue here since we have similar issues every time we connect to a new hostname. I don't think there's an issue on our end.

AxisRay commented 9 months ago

I roughly understand what you're saying. My server doesn't have internet access, but my local machine does (with no firewall limit). In this situation, VSCode attempts to download locally and then upload to the server. The conditions triggering this issue are as described, and you can try to replicate it. I've tested it, and the problem persists in both the insider and stable versions of VSCode. @roblourens

AxisRay commented 9 months ago

Access to XMLHttpRequest at 'https://vscode.download.prss.microsoft.com/dbazure/download/insider/c46c2f1…/vscode_cli_alpine_x64_cli.tar.gz' (redirected from 'https://update.code.visualstudio.com/commit:c46c2f1…/cli-alpine-x64/insider') from origin 'vscode-file://vscode-app' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

My assessment of the cause of this issue is based on the the error message. This error is caused by the Same-Origin Policy enforced by browsers, which restricts web pages from making requests to a domain different from the one that served the web page. In this case, the browser(vscode) is blocking a cross-origin request to 'https://vscode.download.prss.microsoft.com/' because the response does not include the necessary 'Access-Control-Allow-Origin' header.

To resolve this issue, one common approach is to configure CORS headers on the server. The server should include the 'Access-Control-Allow-Origin' header in the response, specifying the allowed domain(s) to access the resource. Alternatively, just set "Access-Control-Allow-Origin" to *.

Therefore, this requires the administrator to configure the CDN correctly.

EISHKARAN commented 9 months ago

@AxisRay I guess being a user I think I found a solution. At least it worked for me hoping it can work for you even. If you are using Mac OS or Linux Go to terminal type in sudo nano /etc/resolv.conf It'll prompt you to give your password enter it and you will be directed to a file In that file you will find the keyword "nameserver" where it is in the next line add this line nameserver 8.8.8.8 Do this in terminal and then go to vscode and try to reconnect to server. Hope it works @roblourens

roblourens commented 9 months ago

Oh, I can repro this. Sorry that it took me so long to get to that point. But if I force Remote-SSH to do a local download, it does fail with this new URL.

camillehe1992 commented 9 months ago

I met the same issue after upgrading the vscode from 1.84.2 to the latest version 1.85.0 last week in windows 11. I didn't find a good workaround, so just reverted to 1.84.2. And it works. Will keep using 1.84.2 till someone or VSCode team address the issue.

drisspg commented 9 months ago

Should the fix be available on insiders already? I am still seeing this issue so I am curious if there is any updates I need to do with vs-code?

Edgar-Nieto-BH commented 9 months ago

Should the fix be available on insiders already? I am still seeing this issue so I am curious if there is any updates I need to do with vs-code?

AFAIK it is already available in 1.85.1, just updated and everything works as expected.

ytwanghaoyu commented 9 months ago

with 1.85.1 the issue seems still exists? image image

ytwanghaoyu commented 9 months ago

@AxisRay I guess being a user I think I found a solution. At least it worked for me hoping it can work for you even. If you are using Mac OS or Linux Go to terminal type in sudo nano /etc/resolv.conf It'll prompt you to give your password enter it and you will be directed to a file In that file you will find the keyword "nameserver" where it is in the next line add this line nameserver 8.8.8.8 Do this in terminal and then go to vscode and try to reconnect to server. Hope it works @roblourens

OK, this solve my problem, since the original nameserver has only a internal server address.

levihuayuzhang commented 8 months ago

when I try to connect to container on a remote machine through SSH:

  1. set up proxy on remote host
  2. add user to docker group (https://docs.docker.com/engine/install/linux-postinstall/)
  3. add proxy for containers (https://docs.docker.com/network/proxy/)
  4. restart remote docker daemon
  5. try to connect and download vscode-server in container on remote machine automatically.
DiegoCao commented 8 months ago

Also encountered this problem, and tried the most common solution:

  1. SSH to the remote server via terminal
  2. Remove the ~/.vscode-server/
    rm -rf ~/.vscode-server/
  3. If remove failed, use lsof to find open files and kill the processes that access files under ~/.vscode-server/
  4. Retry with Vscode

Whenever the connection failed i feel this procedure can resolve the problem in most cases.