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.65k stars 286 forks source link

Tries to start the exec server after failing to connect #9355

Closed roblourens closed 8 months ago

roblourens commented 9 months ago

Seems that after we fail to connect to the remote, resolveExecServer is called which kicks off a second round of trying to connect in the background. Here's the log and also the stack of the call to resolveExecServer, from the dev containers extension.

[15:18:10.753] Downloading VS Code server locally...
[15:18:10.754] Terminating local server
[15:18:10.755] Resolver error: Error: Failed to download VS Code Server (XHR failed 123)
    at SshResolverError.Create (/Users/roblou/code/vscode-remote-ssh/open-ssh-remote/out/extension.js:38981:16)
    at downloadThroughRenderer (/Users/roblou/code/vscode-remote-ssh/open-ssh-remote/out/extension.js:40926:49)
    at downloadAndCopyToHost (/Users/roblou/code/vscode-remote-ssh/open-ssh-remote/out/extension.js:40949:29)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async /Users/roblou/code/vscode-remote-ssh/open-ssh-remote/out/extension.js:41285:9
    at async tryInstallWithLocalServer (/Users/roblou/code/vscode-remote-ssh/open-ssh-remote/out/extension.js:41296:9)
    at async /Users/roblou/code/vscode-remote-ssh/open-ssh-remote/out/extension.js:42675:43
    at async withShowDetailsEvent (/Users/roblou/code/vscode-remote-ssh/open-ssh-remote/out/extension.js:42822:16)
    at async /Users/roblou/code/vscode-remote-ssh/open-ssh-remote/out/extension.js:41238:20
    at async withLock (/Users/roblou/code/vscode-remote-ssh/open-ssh-remote/out/extension.js:41117:20)
    at async resolveWithLocalServer (/Users/roblou/code/vscode-remote-ssh/open-ssh-remote/out/extension.js:41220:12)
    at async prepareResolve (/Users/roblou/code/vscode-remote-ssh/open-ssh-remote/out/extension.js:42524:25)
    at async resolve (/Users/roblou/code/vscode-remote-ssh/open-ssh-remote/out/extension.js:42545:45)
    at async /Users/roblou/code/vscode-remote-ssh/open-ssh-remote/out/extension.js:64375:40
[15:18:10.758] 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":"LocalDownloadFailed","exitCodeLabel":""},"measures":{"resolveAttempts":1,"isExecServer":0,"timing.totalResolveTime":1399,"timing.preSshTime":54,"timing.establishSshTime":1310}}
[15:18:10.761] ------

[15:18:10.762] Local server exit: 15
[15:18:19.567] Opening exec server for ssh-remote+robfast
[15:18:19.598] Initizing new exec server for ssh-remote+robfast
Resolver.resolveExecServer (/Users/roblou/code/vscode-remote-ssh/open-ssh-remote/src/extension.ts:94)
f.getRemoteExecServer (/Applications/Visual Studio Code - Insiders.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:156)
await (Unknown Source:0)
getRemoteExecServer (/Applications/Visual Studio Code - Insiders.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:160)
hJ (/Users/roblou/.vscode-insiders/extensions/ms-vscode-remote.remote-containers-0.329.0/dist/extension/extension.js:291)
iEe (/Users/roblou/.vscode-insiders/extensions/ms-vscode-remote.remote-containers-0.329.0/dist/extension/extension.js:375)

But also, it looks like when the connection was successful and we do this again, it leads to a second ssh call and a second local server? That seems wrong too, I realized I don't understand this flow that well.

connor4312 commented 9 months ago

As in the stack, resolveExecServer is getting called by the remote containers extension trying to get the exec server. So that call is expected, and it will download a 'duplicate' server in the case that the primary connection to the remote is not using the exec server already. If the primary connection is working and is exec server based, then no new connection is made.

Remote containers doesn't actually require a VS Code server until it opens a workspace, only an exec server, so it may not have gotten to the same download failure that the traditional connection did when it tried to install the VS Code server.

So while this scenario looks a little weird, things seem to be working as expected...

roblourens commented 9 months ago

It seems like you shouldn't call resolveExecServer when the initial resolve failed though, and so the window is not connected anyway.

Also, why does the remote container extension do this even before I'm using any remote container features? Seems like this would be an expensive call and we shouldn't do it eagerly. If I use password auth I think I'll get another password prompt.

connor4312 commented 9 months ago

It seems like you shouldn't call resolveExecServer when the initial resolve failed though, and so the window is not connected anyway.

This is called via the API from remote containers -- perhaps it should wait until resolution.

Also, why does the remote container extension do this even before I'm using any remote container features? Seems like this would be an expensive call and we shouldn't do it eagerly. If I use password auth I think I'll get another password prompt.

If there's already an exec server connection available, no extra work is done during connection. I believe dev containers does a feature probe to see what context keys and e.g. commands it should enable; Martin would know more.

vscodenpa commented 9 months ago

This issue has been closed automatically because it needs more information and has not had recent activity. See also our issue reporting guidelines.

Happy Coding!

roblourens commented 8 months ago

This is called via the API from remote containers -- perhaps it should wait until resolution.

I think it should- is that for the extension or for the vscode API implementation?

If there's already an exec server connection available, no extra work is done during connection.

Yeah, but it can be annoying for users who aren't using exec server mode, while we are still in that state

connor4312 commented 8 months ago

is that for the extension or for the vscode API implementation?

Preferably in the extension, I would rather not special case logic in vscode's resolvers for this, cc @chrmarti

vscodenpa commented 8 months ago

This issue has been closed automatically because it needs more information and has not had recent activity. See also our issue reporting guidelines.

Happy Coding!