microsoft / vscode

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

Errors when using proxy support on linux #223393

Open roblourens opened 1 month ago

roblourens commented 1 month ago

Testing #221327

I'm getting these errors when trying to install extensions

2024-07-23 21:07:46.396 [info] Started local extension host with pid 13223.
2024-07-23 21:07:48.997 [info] [perf] Render performance baseline is 12ms
2024-07-23 21:08:03.767 [error] Failed: net::ERR_TUNNEL_CONNECTION_FAILED
    at Y.D (/home/roblou/Downloads/VSCode-linux-arm64/resources/app/out/vs/code/node/sharedProcess/sharedProcessMain.js:105:170102)
    at async Y.B (/home/roblou/Downloads/VSCode-linux-arm64/resources/app/out/vs/code/node/sharedProcess/sharedProcessMain.js:105:166893)
    at async Y.getExtensions (/home/roblou/Downloads/VSCode-linux-arm64/resources/app/out/vs/code/node/sharedProcess/sharedProcessMain.js:105:163417)
    at async F (/home/roblou/Downloads/VSCode-linux-arm64/resources/app/out/vs/code/node/sharedProcess/sharedProcessMain.js:105:71516)
    at async z.M (/home/roblou/Downloads/VSCode-linux-arm64/resources/app/out/vs/code/node/sharedProcess/sharedProcessMain.js:105:71995)
    at async /home/roblou/Downloads/VSCode-linux-arm64/resources/app/out/vs/code/node/sharedProcess/sharedProcessMain.js:105:65447
    at async Promise.all (index 0)
    at async z.I (/home/roblou/Downloads/VSCode-linux-arm64/resources/app/out/vs/code/node/sharedProcess/sharedProcessMain.js:105:65234)
    at async z.installGalleryExtensions (/home/roblou/Downloads/VSCode-linux-arm64/resources/app/out/vs/code/node/sharedProcess/sharedProcessMain.js:105:62367)
    at async z.installFromGallery (/home/roblou/Downloads/VSCode-linux-arm64/resources/app/out/vs/code/node/sharedProcess/sharedProcessMain.js:105:61510)
2024-07-23 21:08:03.782 [error] net::ERR_TUNNEL_CONNECTION_FAILED: Failed: net::ERR_TUNNEL_CONNECTION_FAILED
    at Y.D (/home/roblou/Downloads/VSCode-linux-arm64/resources/app/out/vs/code/node/sharedProcess/sharedProcessMain.js:105:170102)
    at async Y.B (/home/roblou/Downloads/VSCode-linux-arm64/resources/app/out/vs/code/node/sharedProcess/sharedProcessMain.js:105:166893)
    at async Y.getExtensions (/home/roblou/Downloads/VSCode-linux-arm64/resources/app/out/vs/code/node/sharedProcess/sharedProcessMain.js:105:163417)
    at async F (/home/roblou/Downloads/VSCode-linux-arm64/resources/app/out/vs/code/node/sharedProcess/sharedProcessMain.js:105:71516)
    at async z.M (/home/roblou/Downloads/VSCode-linux-arm64/resources/app/out/vs/code/node/sharedProcess/sharedProcessMain.js:105:71995)
    at async /home/roblou/Downloads/VSCode-linux-arm64/resources/app/out/vs/code/node/sharedProcess/sharedProcessMain.js:105:65447
    at async Promise.all (index 0)
    at async z.I (/home/roblou/Downloads/VSCode-linux-arm64/resources/app/out/vs/code/node/sharedProcess/sharedProcessMain.js:105:65234)
    at async z.installGalleryExtensions (/home/roblou/Downloads/VSCode-linux-arm64/resources/app/out/vs/code/node/sharedProcess/sharedProcessMain.js:105:62367)
    at async z.installFromGallery (/home/roblou/Downloads/VSCode-linux-arm64/resources/app/out/vs/code/node/sharedProcess/sharedProcessMain.js:105:61510)
2024-07-23 21:08:20.291 [error] Error: net::ERR_TUNNEL_CONNECTION_FAILED
    at SimpleURLLoaderWrapper.<anonymous> (node:electron/js2c/browser_init:2:114482)
    at SimpleURLLoaderWrapper.emit (node:events:519:28)
2024-07-23 21:08:20.310 [error] net::ERR_TUNNEL_CONNECTION_FAILED: Error: net::ERR_TUNNEL_CONNECTION_FAILED
    at SimpleURLLoaderWrapper.<anonymous> (node:electron/js2c/browser_init:2:114482)
    at SimpleURLLoaderWrapper.emit (node:events:519:28)
2024-07-23 21:08:34.310 [error] Failed: net::ERR_TUNNEL_CONNECTION_FAILED
    at Y.D (/home/roblou/Downloads/VSCode-linux-arm64/resources/app/out/vs/code/node/sharedProcess/sharedProcessMain.js:105:170102)
    at async Y.B (/home/roblou/Downloads/VSCode-linux-arm64/resources/app/out/vs/code/node/sharedProcess/sharedProcessMain.js:105:166893)
    at async Y.getExtensions (/home/roblou/Downloads/VSCode-linux-arm64/resources/app/out/vs/code/node/sharedProcess/sharedProcessMain.js:105:163417)
    at async F (/home/roblou/Downloads/VSCode-linux-arm64/resources/app/out/vs/code/node/sharedProcess/sharedProcessMain.js:105:71516)
    at async z.M (/home/roblou/Downloads/VSCode-linux-arm64/resources/app/out/vs/code/node/sharedProcess/sharedProcessMain.js:105:71995)
    at async /home/roblou/Downloads/VSCode-linux-arm64/resources/app/out/vs/code/node/sharedProcess/sharedProcessMain.js:105:65447
    at async Promise.all (index 0)
    at async z.I (/home/roblou/Downloads/VSCode-linux-arm64/resources/app/out/vs/code/node/sharedProcess/sharedProcessMain.js:105:65234)
    at async z.installGalleryExtensions (/home/roblou/Downloads/VSCode-linux-arm64/resources/app/out/vs/code/node/sharedProcess/sharedProcessMain.js:105:62367)
    at async z.installFromGallery (/home/roblou/Downloads/VSCode-linux-arm64/resources/app/out/vs/code/node/sharedProcess/sharedProcessMain.js:105:61510)
2024-07-23 21:08:34.323 [error] net::ERR_TUNNEL_CONNECTION_FAILED: Failed: net::ERR_TUNNEL_CONNECTION_FAILED
    at Y.D (/home/roblou/Downloads/VSCode-linux-arm64/resources/app/out/vs/code/node/sharedProcess/sharedProcessMain.js:105:170102)
    at async Y.B (/home/roblou/Downloads/VSCode-linux-arm64/resources/app/out/vs/code/node/sharedProcess/sharedProcessMain.js:105:166893)
    at async Y.getExtensions (/home/roblou/Downloads/VSCode-linux-arm64/resources/app/out/vs/code/node/sharedProcess/sharedProcessMain.js:105:163417)
    at async F (/home/roblou/Downloads/VSCode-linux-arm64/resources/app/out/vs/code/node/sharedProcess/sharedProcessMain.js:105:71516)
    at async z.M (/home/roblou/Downloads/VSCode-linux-arm64/resources/app/out/vs/code/node/sharedProcess/sharedProcessMain.js:105:71995)
    at async /home/roblou/Downloads/VSCode-linux-arm64/resources/app/out/vs/code/node/sharedProcess/sharedProcessMain.js:105:65447
    at async Promise.all (index 0)
    at async z.I (/home/roblou/Downloads/VSCode-linux-arm64/resources/app/out/vs/code/node/sharedProcess/sharedProcessMain.js:105:65234)
    at async z.installGalleryExtensions (/home/roblou/Downloads/VSCode-linux-arm64/resources/app/out/vs/code/node/sharedProcess/sharedProcessMain.js:105:62367)
    at async z.installFromGallery (/home/roblou/Downloads/VSCode-linux-arm64/resources/app/out/vs/code/node/sharedProcess/sharedProcessMain.js:105:61510)

Image

chrmarti commented 1 month ago

Also seeing this in 1.91.1 on Linux with a basic auth proxy.

chrmarti commented 1 month ago

It works when the proxy doesn't require authentication. It also work with basic auth using https and fetch in the extension host.

deepak1556 commented 1 month ago

Shared process uses the net API from the main process which doesn't use the proxy auth feature I added recently, it will be addressed with https://github.com/microsoft/vscode/issues/223452

chrmarti commented 1 month ago

@deepak1556 This seems to work on Windows and macOS, so maybe there is a bug separate from https://github.com/microsoft/vscode/issues/223452.

deepak1556 commented 1 month ago

Oh that is interesting, I always assumed all extension requests are triggered from the shared process which go through the main process net API and any proxy requiring basic auth should have failed these requests. But you are right, given the requests pass on macOS and windows there must be a difference I am missing. I looked at the network logs and this is what I see on macOS

1) Requests to update service, telemetry use the main process net api and they are failing with ERR_TUNNEL_CONNECTION_FAILED as expected. 2) Requests to marketplace.visualstudio.com seems to be happening from the renderer process and these will get the auth dialog causing them to work as expected. The initiator = "vscode-file://vscode-app" seems to confirm that the requests are triggered from workbench.

I am wondering how this looks like on linux. @chrmarti can you share the netlog, maybe also use a fresh user data dir and extensions dir to avoid http caches.

chrmarti commented 1 month ago

Using a PAC script I see some PAC related errors, will retry without PAC script to be isolate. Attaching netlog with PAC script.

linux-basic-auth-proxy-netlog-with-pac-script.json

chrmarti commented 1 month ago

Without PAC script worked:

linux-basic-auth-proxy-netlog.json

The PAC script is simple:

function FindProxyForURL(url, host) {
    if (dnsDomainIs(host, "marketplace.visualstudio.com"))
        return "PROXY localhost:3111";
    return "PROXY localhost:3122";
}

And it works on Windows and macOS and also when triggered from the extension host on Linux. Is the PAC script evaluated differently when queried from the extension host? For https we are going through Electron.Session.resolveProxy in the main process, for fetch I don't know.

My test setup uses the dev container at https://github.com/microsoft/vscode-proxy-agent/tree/main/.devcontainer/basic-auth-test to run the proxies and serve the PAC script.