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.55k stars 263 forks source link

Pre-open tasks for remote tunnel connections #9981

Open Datata1 opened 2 weeks ago

Datata1 commented 2 weeks ago

Hello there,

Currently, I am developing an extension that utilizes the functionality of the VS Code Remote Tunnels extension. My extension enables users of our IaaS platform to create tunnels within VS Code to connect to their servers, allowing them to access and modify code directly on their servers.

We offer an "on-demand server" category that shuts down after 60 minutes of inactivity. If a user closes VS Code and reopens it after 60 minutes or more, VS Code cannot connect to the server to establish a tunnel connection because the server is shut down.

In summary, what I need is the ability to execute certain tasks before the remote tunnel connection is successfully established. Specifically, I need to send a URL request to our services to start the server. Currently, our extension only supports servers that are continuously available (24/7). For users with an on-demand workspace that has been shut down, they currently have to manually start the server on our website, which is not optimal for user experience.

A similar feature request was submitted last year and added to your backlog (#8636). I'm hoping there is a solution to this issue, as it is crucial for our extension to be published as a stable release.

Things I have already tried:

This is the extension log when attempting to connect to a shutdown server:

2024-06-16 17:30:59.395 [info] Extension host with pid 55036 exiting with code 0
2024-06-16 17:31:00.671 [info] Extension host with pid 55504 started
2024-06-16 17:31:00.671 [info] Skipping acquiring lock for /home/jan-david/.config/Code/User/workspaceStorage/c3d95f04922cc1e3717ddf5991976dcf.
2024-06-16 17:31:00.671 [info] $getCanonicalURI invoked for authority (tunnel)
2024-06-16 17:31:00.674 [info] ExtensionService#_doActivateExtension ms-vscode.remote-server, startup: false, activationEvent: 'onResolveRemoteAuthority:tunnel'
2024-06-16 17:31:00.710 [info] [resolveAuthority(tunnel,1)][0ms] activating remote resolvers tunnel+vscode-extension-12
2024-06-16 17:31:00.710 [info] [resolveAuthority(tunnel,1)][0ms] activating resolver for tunnel+vscode-extension-12...
2024-06-16 17:31:00.710 [info] [resolveAuthority(tunnel,1)][0ms] invoking final resolve()...
2024-06-16 17:31:01.223 [info] ExtensionService#_doActivateExtension vscode.github-authentication, startup: false, activationEvent: 'onAuthenticationRequest:github'
2024-06-16 17:31:01.711 [info] [resolveAuthority(tunnel,1)][1001ms] waiting...
2024-06-16 17:31:02.722 [info] [resolveAuthority(tunnel,1)][2012ms] waiting...
2024-06-16 17:31:03.723 [info] [resolveAuthority(tunnel,1)][3013ms] waiting...
2024-06-16 17:31:04.723 [info] [resolveAuthority(tunnel,1)][4013ms] waiting...
2024-06-16 17:31:05.723 [info] [resolveAuthority(tunnel,1)][5013ms] waiting...
2024-06-16 17:31:06.724 [info] [resolveAuthority(tunnel,1)][6014ms] waiting...
2024-06-16 17:31:06.950 [info] [resolveAuthority(tunnel,1)][6240ms] setting tunnel factory...
2024-06-16 17:31:06.950 [info] [resolveAuthority(tunnel,1)][6240ms] returned 127.0.0.1:37141
2024-06-16 17:31:37.004 [info] [resolveAuthority(tunnel,2)][1ms] activating remote resolvers tunnel+vscode-extension-12
2024-06-16 17:31:37.004 [info] [resolveAuthority(tunnel,2)][1ms] activating resolver for tunnel+vscode-extension-12...
2024-06-16 17:31:37.004 [info] [resolveAuthority(tunnel,2)][1ms] invoking final resolve()...
2024-06-16 17:31:38.005 [info] [resolveAuthority(tunnel,2)][1002ms] waiting...
2024-06-16 17:31:38.284 [info] [resolveAuthority(tunnel,2)][1281ms] setting tunnel factory...
2024-06-16 17:31:38.284 [info] [resolveAuthority(tunnel,2)][1281ms] returned 127.0.0.1:45337
2024-06-16 17:32:08.326 [info] [resolveAuthority(tunnel,3)][0ms] activating remote resolvers tunnel+vscode-extension-12
2024-06-16 17:32:08.326 [info] [resolveAuthority(tunnel,3)][0ms] activating resolver for tunnel+vscode-extension-12...
2024-06-16 17:32:08.326 [info] [resolveAuthority(tunnel,3)][0ms] invoking final resolve()...
2024-06-16 17:32:09.327 [info] [resolveAuthority(tunnel,3)][1001ms] waiting...
2024-06-16 17:32:09.620 [info] [resolveAuthority(tunnel,3)][1294ms] setting tunnel factory...
2024-06-16 17:32:09.620 [info] [resolveAuthority(tunnel,3)][1294ms] returned 127.0.0.1:46481
2024-06-16 17:32:39.669 [info] [resolveAuthority(tunnel,4)][0ms] activating remote resolvers tunnel+vscode-extension-12
2024-06-16 17:32:39.669 [info] [resolveAuthority(tunnel,4)][0ms] activating resolver for tunnel+vscode-extension-12...
2024-06-16 17:32:39.669 [info] [resolveAuthority(tunnel,4)][0ms] invoking final resolve()...
2024-06-16 17:32:40.670 [info] [resolveAuthority(tunnel,4)][1001ms] waiting...
2024-06-16 17:32:41.162 [info] [resolveAuthority(tunnel,4)][1493ms] setting tunnel factory...
2024-06-16 17:32:41.163 [info] [resolveAuthority(tunnel,4)][1494ms] returned 127.0.0.1:37019
2024-06-16 17:33:11.209 [info] [resolveAuthority(tunnel,5)][0ms] activating remote resolvers tunnel+vscode-extension-12
2024-06-16 17:33:11.209 [info] [resolveAuthority(tunnel,5)][0ms] activating resolver for tunnel+vscode-extension-12...
2024-06-16 17:33:11.210 [info] [resolveAuthority(tunnel,5)][1ms] invoking final resolve()...
2024-06-16 17:33:12.211 [info] [resolveAuthority(tunnel,5)][1002ms] waiting...
2024-06-16 17:33:12.562 [info] [resolveAuthority(tunnel,5)][1353ms] setting tunnel factory...
2024-06-16 17:33:12.563 [info] [resolveAuthority(tunnel,5)][1354ms] returned 127.0.0.1:35775
2024-06-16 17:33:42.899 [info] ExtensionService#_doActivateExtension johnpapa.vscode-peacock, startup: true, activationEvent: '*'
2024-06-16 17:33:42.904 [error] CodeExpectedError: ENOPRO: No file system provider found for resource 'vscode-remote://tunnel%2Bvscode-extension-12/home/user/app'
    at s.j (vscode-file://vscode-app/usr/share/code/resources/app/out/vs/workbench/workbench.desktop.main.js:658:14838)
    at async s.exists (vscode-file://vscode-app/usr/share/code/resources/app/out/vs/workbench/workbench.desktop.main.js:658:17045)
    at async Promise.all (index 0)
    at async vscode-file://vscode-app/usr/share/code/resources/app/out/vs/workbench/workbench.desktop.main.js:1716:2988
2024-06-16 17:33:42.904 [info] ExtensionService#_doActivateExtension ms-vscode.remote-explorer, startup: false, activationEvent: 'onCommand:remote-internal.setActiveFolders'
2024-06-16 17:33:43.002 [info] Eager extensions activated
2024-06-16 17:33:43.010 [info] ExtensionService#_doActivateExtension ms-vscode-remote.remote-containers, startup: false, activationEvent: 'onStartupFinished'
2024-06-16 17:33:43.049 [info] ExtensionService#_doActivateExtension ms-vscode-remote.remote-wsl, startup: false, activationEvent: 'onStartupFinished'
2024-06-16 17:33:43.062 [info] ExtensionService#_doActivateExtension PKief.material-icon-theme, startup: false, activationEvent: 'onStartupFinished'
2024-06-16 17:33:43.074 [info] ExtensionService#_doActivateExtension ms-vscode-remote.remote-ssh, startup: false, activationEvent: 'onCommand:remote-internal.getActiveSshRemote'
2024-06-16 17:33:43.094 [info] ExtensionService#_doActivateExtension vscode.microsoft-authentication, startup: false, activationEvent: 'onAuthenticationRequest:microsoft'
2024-06-16 17:34:14.975 [error] Error: Timeout connecting to relay
    at Timeout._onTimeout (/home/jan-david/.vscode/extensions/ms-vscode.remote-server-1.5.2/dist/node/extension.js:2:925445)
    at listOnTimeout (node:internal/timers:569:17)
    at process.processTimers (node:internal/timers:512:7)
Datata1 commented 2 weeks ago

image

In this picture you can see that my extension is there but not loaded. This happens while the tunnel tries to connect to our shut down server. Ideally our extension will be activated during or even before the tunnel connection, so that we can place an URL request within our activation function of our extension.

Datata1 commented 2 weeks ago

I have been trying to find a solution to this problem over the past few days and I came across the tunnels, tunnelFactory, and resolvers proposed APIs. Among these proposed APIs, I found a method that seems very promising for solving the issue of scaling tunnel servers: https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.resolvers.d.ts

image

However, because this is proposed API, it doesn't make sense to further develop my extension. In the end, I cannot publish this extension as a stable version since only Code - Insiders clients can use the proposed API, and I need to modify the user's argv.json file to enable it.

I found several resources on the internet referencing this resolver proposed API, with the earliest mention dating back to 2019: https://github.com/microsoft/vscode/issues/73551 (2019) https://github.com/microsoft/vscode/issues/210367 (2024) https://gitlab.com/gitlab-org/gitlab/-/issues/370122 (2023) https://gitlab.com/gitlab-org/gitlab/-/issues/370123 (2023)

Additionally, I read that VS Code has some forever proposed APIs: https://github.com/microsoft/vscode/issues/131165 image

In this GitLab thread, I read that some specific extensions are allowed to use the proposed API in stable VS Code, and it makes sense that the remote extensions are allowed to use these: https://gitlab.com/gitlab-org/gitlab/-/issues/370123

@chrmarti, is the VS Code team planning to release these proposed APIs in the future or will these proposed APIs stay proposed because of any concerns mentioned in the last attached screenshot of this comment? Or is there already an existing way to solve that problem without using code-insider clients? For us, it doesn't make sense to have a development server online 24/7 just to work up to a few hours a day on a cloud-hosted project. While it is possible to manually start the server on our website, this is not a good developer experience when using our extension. As a user, I want to open VS Code and start coding on my project right away without wasting money keeping a development server running when it is not in use.

A similar feature-request was added to the backlog las year #8636