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.67k stars 293 forks source link

Ports do not get forwarded from WSL to Windows #8350

Closed christasich closed 1 year ago

christasich commented 1 year ago

In the latest version of remote-wsl (0.78.0), vscode intermittently does not foward ports to Windows. This can sometimes be resolved (or caused) by restarting WSL (wsl.exe --shutdown).

I first encountered this error while trying to view a PDF in WSL using the Latex Workshop extension. The PDF is served on a random port that is then accessed remotely (127.0.0.1:PORT). ss -tulpn shows that the ports are setup correctly on the WSL side, but nmap shows the matching ports as closed on the Windows side. James-Yu/LaTex-Workshop/#3826 may be referencing this same issue. Downgrading to v0.77.0 fixes the issue for me.

Possibly related: I'm using a split tunnel VPN (Wireguard) for DNS resolution.

exthost.log

2023-04-11 15:52:42.275 [info] Extension host with pid 24496 started
2023-04-11 15:52:42.276 [info] Skipping acquiring lock for c:\Users\chris\AppData\Roaming\Code - Insiders\User\workspaceStorage\b5939f8be1c7f8aa33b1031f597bd616.
2023-04-11 15:52:42.276 [info] $getCanonicalURI invoked for authority (wsl)
2023-04-11 15:52:42.286 [info] ExtensionService#_doActivateExtension ms-vscode-remote.remote-wsl, startup: false, activationEvent: 'onResolveRemoteAuthority:wsl'
2023-04-11 15:52:42.334 [info] [resolveAuthority(wsl,1)][0ms] activating resolver...
2023-04-11 15:52:42.334 [info] [resolveAuthority(wsl,1)][0ms] setting tunnel factory...
2023-04-11 15:52:42.334 [info] [resolveAuthority(wsl,1)][0ms] invoking resolve()...
2023-04-11 15:52:43.255 [info] [resolveAuthority(wsl,1)][921ms] returned 127.0.0.1:64338
2023-04-11 15:52:45.618 [info] ExtensionService#_doActivateExtension vscode.github-authentication, startup: false, activationEvent: 'onAuthenticationRequest:github'
2023-04-11 15:52:46.565 [info] Eager extensions activated
2023-04-11 15:52:46.567 [info] ExtensionService#_doActivateExtension vscode.microsoft-authentication, startup: false, activationEvent: 'onAuthenticationRequest:microsoft'
2023-04-11 15:52:46.585 [info] ExtensionService#_doActivateExtension aaron-bond.better-comments, startup: false, activationEvent: 'onStartupFinished'
2023-04-11 15:52:46.605 [info] ExtensionService#_doActivateExtension alefragnani.Bookmarks, startup: false, activationEvent: 'onStartupFinished'
2023-04-11 15:52:46.614 [info] ExtensionService#_doActivateExtension ms-vscode-remote.remote-containers, startup: false, activationEvent: 'onStartupFinished'
2023-04-11 15:52:46.670 [info] ExtensionService#_doActivateExtension PKief.material-icon-theme, startup: false, activationEvent: 'onStartupFinished'
2023-04-11 15:52:46.678 [info] ExtensionService#_doActivateExtension usernamehw.errorlens, startup: false, activationEvent: 'onStartupFinished'
2023-04-11 15:52:49.796 [error] TypeError: (0 , i.localize) is not a function
    at Object.showLog (c:\Users\chris\.vscode-insiders\extensions\ms-vscode-remote.remote-wsl-0.78.0\dist\extension.js:2:614204)
    at c:\Users\chris\.vscode-insiders\extensions\ms-vscode-remote.remote-wsl-0.78.0\dist\extension.js:2:583190
    at v.h (c:\Users\chris\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:98:126110)
    at v.$executeContributedCommand (c:\Users\chris\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:98:127013)
    at a.N (c:\Users\chris\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:108:11655)
    at a.M (c:\Users\chris\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:108:11373)
    at a.H (c:\Users\chris\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:108:10454)
    at a.G (c:\Users\chris\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:108:9432)
    at c:\Users\chris\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:108:8220
    at b.invoke (c:\Users\chris\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:63:145)
    at m.deliver (c:\Users\chris\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:63:2121)
    at n.fire (c:\Users\chris\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:63:1729)
    at g.fire (c:\Users\chris\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:72:14915)
    at c:\Users\chris\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:124:32338
    at b.invoke (c:\Users\chris\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:63:145)
    at m.deliver (c:\Users\chris\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:63:2121)
    at n.fire (c:\Users\chris\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:63:1729)
    at g.fire (c:\Users\chris\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:72:14915)
    at MessagePortMain.<anonymous> (c:\Users\chris\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:124:30464)
    at MessagePortMain.emit (node:events:513:28)
    at MessagePortMain._internalPort.emit (node:electron/js2c/utility_init:2:367) remote-wsl.showLog {"value":"ms-vscode-remote.remote-wsl","c":"ms-vscode-remote.remote-wsl"}

For comparison, here's the log from v0.77.0.

exthost.log (v0.77.0)

2023-04-11 14:47:14.037 [info] Extension host with pid 9344 started
2023-04-11 14:47:14.037 [info] Skipping acquiring lock for c:\Users\chris\AppData\Roaming\Code - Insiders\User\workspaceStorage\b5939f8be1c7f8aa33b1031f597bd616.
2023-04-11 14:47:14.037 [info] $getCanonicalURI invoked for authority (wsl)
2023-04-11 14:47:14.052 [info] ExtensionService#_doActivateExtension ms-vscode-remote.remote-wsl, startup: false, activationEvent: 'onResolveRemoteAuthority:wsl'
2023-04-11 14:47:14.251 [info] [resolveAuthority(wsl,1)][0ms] activating resolver...
2023-04-11 14:47:14.251 [info] [resolveAuthority(wsl,1)][0ms] setting tunnel factory...
2023-04-11 14:47:14.251 [info] [resolveAuthority(wsl,1)][1ms] invoking resolve()...
2023-04-11 14:47:15.179 [info] [resolveAuthority(wsl,1)][929ms] returned 127.0.0.1:63315
2023-04-11 14:47:18.202 [info] ExtensionService#_doActivateExtension vscode.github-authentication, startup: false, activationEvent: 'onAuthenticationRequest:github'
2023-04-11 14:47:19.569 [info] ExtensionService#_doActivateExtension vscode.microsoft-authentication, startup: false, activationEvent: 'onAuthenticationRequest:microsoft'
2023-04-11 14:47:19.596 [info] Eager extensions activated
2023-04-11 14:47:19.973 [info] ExtensionService#_doActivateExtension aaron-bond.better-comments, startup: false, activationEvent: 'onStartupFinished'
2023-04-11 14:47:19.986 [info] ExtensionService#_doActivateExtension alefragnani.Bookmarks, startup: false, activationEvent: 'onStartupFinished'
2023-04-11 14:47:19.992 [info] ExtensionService#_doActivateExtension ms-vscode-remote.remote-containers, startup: false, activationEvent: 'onStartupFinished'
2023-04-11 14:47:20.044 [info] ExtensionService#_doActivateExtension PKief.material-icon-theme, startup: false, activationEvent: 'onStartupFinished'
2023-04-11 14:47:20.061 [info] ExtensionService#_doActivateExtension usernamehw.errorlens, startup: false, activationEvent: 'onStartupFinished'
2023-04-11 14:48:18.870 [info] Extension host terminating: renderer closed the MessagePort
2023-04-11 14:48:18.872 [info] Extension host with pid 9344 exiting with code 0

Steps to Reproduce:

  1. Install v0.77.0 (code-insiders --install-extension ms-vscode-remote.remote-wsl@0.77.0)
  2. Open vscode and connect to WSL.
  3. WSL > Show log (always works)
  4. View PDF using Latex Workshop (always works)
  5. Close vscode.
  6. Upgrade to v0.78.0 (code-insiders --install-extension ms-vscode-remote.remote-wsl@0.78.0)
  7. Open vscode and connect to WSL.
  8. WSL > Show log (intermittently fails silently)
  9. View PDF using Latex Workshop (intermittently fails; error shown in "Main" log [error] CodeWindow: failed to load (reason: ERR_CONNECTION_REFUSED, code: -102))

Does this issue occur when you try this locally?: No

Note: Enabling setting remote.WSL.debug to true prevents WSL from starting at all in v0.78.0. The log shows an endless loop of resolveAuthority(wsl,1) (below) and no log file is created on the Windows side at %APPDATA%\Code - Insiders\logs\.

exthost.log (v0.78.0) with remote.WSL.debug enabled

2023-04-11 14:48:23.315 [info] Extension host with pid 24600 started
2023-04-11 14:48:23.315 [info] Skipping acquiring lock for c:\Users\chris\AppData\Roaming\Code - Insiders\User\workspaceStorage\b5939f8be1c7f8aa33b1031f597bd616.
2023-04-11 14:48:23.326 [info] $getCanonicalURI invoked for authority (wsl)
2023-04-11 14:48:23.355 [info] ExtensionService#_doActivateExtension ms-vscode-remote.remote-wsl, startup: false, activationEvent: 'onResolveRemoteAuthority:wsl'
2023-04-11 14:48:23.712 [info] [resolveAuthority(wsl,1)][0ms] activating resolver...
2023-04-11 14:48:23.713 [info] [resolveAuthority(wsl,1)][0ms] setting tunnel factory...
2023-04-11 14:48:23.713 [info] [resolveAuthority(wsl,1)][1ms] invoking resolve()...
2023-04-11 14:48:24.723 [info] [resolveAuthority(wsl,1)][1011ms] waiting...
2023-04-11 14:48:24.843 [error] TypeError: (0 , i.localize) is not a function
    at Object.showLog (c:\Users\chris\.vscode-insiders\extensions\ms-vscode-remote.remote-wsl-0.78.0\dist\extension.js:2:614204)
    at m (c:\Users\chris\.vscode-insiders\extensions\ms-vscode-remote.remote-wsl-0.78.0\dist\extension.js:2:602890)
    at c:\Users\chris\.vscode-insiders\extensions\ms-vscode-remote.remote-wsl-0.78.0\dist\extension.js:2:606125
    at new Promise (<anonymous>)
    at O._resolve (c:\Users\chris\.vscode-insiders\extensions\ms-vscode-remote.remote-wsl-0.78.0\dist\extension.js:2:602061)
    at c:\Users\chris\.vscode-insiders\extensions\ms-vscode-remote.remote-wsl-0.78.0\dist\extension.js:2:600849
    at D.d (c:\Users\chris\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:98:46085)
    at D.withProgress (c:\Users\chris\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:98:45928)
    at Object.withProgress (c:\Users\chris\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:114:34180)
    at O.resolve (c:\Users\chris\.vscode-insiders\extensions\ms-vscode-remote.remote-wsl-0.78.0\dist\extension.js:2:600746)
    at process.processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async b.$resolveAuthority (c:\Users\chris\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:110:18631)
2023-04-11 14:48:25.724 [info] [resolveAuthority(wsl,1)][2011ms] waiting...
2023-04-11 14:48:26.738 [info] [resolveAuthority(wsl,1)][3026ms] waiting...
2023-04-11 14:48:27.753 [info] [resolveAuthority(wsl,1)][4041ms] waiting...
2023-04-11 14:48:28.757 [info] [resolveAuthority(wsl,1)][5045ms] waiting...
2023-04-11 14:48:29.766 [info] [resolveAuthority(wsl,1)][6053ms] waiting...
(continued)
christasich commented 1 year ago

Of course, right after I submitted this. I started getting the issue in v0.77.0. So it seems downgrading does not resolve it for me. Of note though is that the "WSL > Show log" option does work in =<0.77.0, but not in v0.78.0. I think this is a larger issue likely related to WSL itself.

christasich commented 1 year ago

It looks like the issue was just identified here https://github.com/microsoft/WSL/issues/9947 and a fix is in bound.