microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
163.79k stars 29.11k forks source link

[BUG] TunnelFactory Proposed API: registerTunnelProvider doesn't update the ports to the UI #210367

Closed jonathanpv closed 6 months ago

jonathanpv commented 6 months ago

Does this issue occur when all extensions are disabled?: Yes/No

Steps to Reproduce:

  1. Go to https://github.com/jonathanpv/codecontext and git clone, install in visual studio code insiders, then try running the command to share context, the port forwards successfully but doesn't display in the vscode opened ports view
  2. See it opens the port here image

I can also access it on the web since its public

image

however in the ports view i don't get to see the fact its been opened

image

is this because its still in preview? or doesn't work in dev mode?

jonathanpv commented 6 months ago

@connor4312 would like thoughts on this

here's my extension repo https://github.com/jonathanpv/codecontext

and the issue https://github.com/jonathanpv/codecontext/issues/1

jonathanpv commented 6 months ago

I could be misusing the api though, so could just be my fault entirely

alexr00 commented 6 months ago

@jonathanpv some questions and thoughts:

jonathanpv commented 6 months ago

@jonathanpv some questions and thoughts:

  • Are you running your extension when connected to a remote (ex. using the Remote SSH extension)?

No I'm port forwarding only local ports and my code is nearly identical to

  • It sounds like you're expecting that processes that listen on a port and are running in the same place as your extension get automatically picked up by VS Code and then forwarded using your tunnel provider. This will only happen if you're also connected to a remote. If you're connected to a remote, then this is controlled by the remote.autoForwardPorts and remote.autoForwardPortsSource settings. Even if you're connect to a remote I don't think this should work as then the remote extension controls the tunnel provider.

Hmm unsure about the remote, but highlevel overview my extension is:

i have the repo with my example up and should be reproducible, but i can provide a video if need be to showcase the issue more clearly

  • Also proposed API, which we don't have a plan to finalize: the openTunnel can also be used to cause VS Code to forward a port (which would eventually call your tunnel provider.

Hmm, I'll check openTunnel, I ended up using provideTunnel from the example I saw from the built-in tunnel-forwarding extension, let me check that one out

alexr00 commented 6 months ago
  • i can then access the url by going through the extension output logs but i have to manually check the logs and add the port from the template URL which usually looks something like asdf123-{PORT}.devtunnels.com

  • i'd like to be able to copy the url from the ports tab and I believed the registerTunnelProvider would've gotten me that

I think a screen recording would help me understand.

registerTunnelProvider basically just powers the "Ports" view. It is not expected that extensions call provideTunnel. That should only be called by VS Code.

jonathanpv commented 6 months ago

So update, using openTunnel from the proposed 'tunnels' api does update the ports UI

Think I can simplify my code now to use that instead of tunnelFactory

alexr00 commented 6 months ago

tunnelFactory is for extension that know how to forward ports and actually implement port forwarding.

openTunnel is for extensions that know about a port that needs to be forwarded and want to cause it to be forwarded.