coder / code-server

VS Code in the browser
https://coder.com
MIT License
66.47k stars 5.45k forks source link

no_proxy is not working on code-server #6811

Open lionelhe opened 1 month ago

lionelhe commented 1 month ago

Is there an existing issue for this?

OS/Web Information

Steps to Reproduce

  1. Install Code-marketplace on your kubernetes cluster
  2. Create a code-server with env variable to access this code-marketplace inside the cluster (using svc.cluster.local) EXTENSIONS_GALLERY={"serviceUrl":"http://code-marketplace.code-marketplace.svc.cluster.local/api", "itemUrl":"http://code-marketplace.code-marketplace.svc.cluster.local/item", "resourceUrlTemplate": "http://code-marketplace.code-marketplace.svc.cluster.local/files/{publisher}/{name}/{version}/{path}"}
  3. Also add variable environment for corporate proxy + put cluster.local as no_proxy http_proxy="http://corporate-proxy.com" https_proxy="$http_proxy" no_proxy=".cluster.local,.cluster.local."
  4. Open Code-server
  5. Go in extensions tab to install extension

Expected

We should be able to see all plugins proposed in our cluster code-marketplace and install them

Actual

We get error: Error while fetching extensions. Proxy connection ended before receiving CONNECT response.

Logs

No response

Screenshot/Video

No response

Does this bug reproduce in native VS Code?

I did not test native VS Code

Does this bug reproduce in GitHub Codespaces?

I did not test GitHub Codespaces

Are you accessing code-server over a secure context?

Notes

It seems to go through proxy even with no_proxy env variable set.

Without http_proxy set, it correctly connect to code-marketplace.

It seems to be coherent with the last status on coder/vscode https://github.com/coder/code-server/issues/4672#issuecomment-1004402012

code-asher commented 1 month ago

Is it failing to install the extensions or is it failing to list them at all? The listing request is sent from the browser, while the install happens from the backend, so I wonder if that has something to do with it.

lionelhe commented 1 month ago

It is failing to get the extension list. Not sure it is requesting from browser though because without the proxy, I can list them even while I do not have access to svc.cluster.local from my browser.

I guess more than proxy-agent used by coder/vscode does not succeed to use no_proxy env variable.

Maybe use of last version of proxy-agent Can correct that. I also see that Microsoft vscode did have to do some change to make it work https://github.com/microsoft/vscode/pull/147981#issue-1213370025

code-asher commented 1 month ago

The list query is supposed to run from the browser. If your browser does not have access to svc.cluster.local that would explain the error.

code-asher commented 1 month ago

Er wait, maybe I misread. You said you can list them without the proxy? I am not entirely sure what is going on then. Maybe check the network tab in the browser dev tools and check to see if the requests are failing.

code-asher commented 1 month ago

That no_proxy fix does seem promising though.

lionelhe commented 1 month ago

Er wait, maybe I misread. You said you can list them without the proxy? I am not entirely sure what is going on then. Maybe check the network tab in the browser dev tools and check to see if the requests are failing.

Yes I "can" without the proxy By testing with the dev tool, I sure have some error of extension listing on network but it is like it somehow use server-side request if it cannot find extensions from browser requests...

That no_proxy fix does seem promising though. It does, it has not been merged on vscode but it seems to have been accepted on che-code https://github.com/che-incubator/che-code/pull/234

code-asher commented 1 month ago

Interesting, yeah searching extensions happens purely from the browser, so the server should not be involved. You should see a POST request to https://open-vsx.org/vscode/gallery/extensionquery, if that errors then no extensions will be shown.

lionelhe commented 1 month ago

Ok so on my case I use a code-marketplace in my kubernetes cluster on which I have my code-servers.

I tried to use direct local connection (using svc.cluster.local) but it did not work for browser side obviously...

I played a little with the EXTENSIONS_GALLERY environment variable and added an ingress to be able to get access to my store from my browser.

It seems that putting serviceUrl on my ingress permits me to correctly get the list of my extensions from my browser. It does not correct the no_proxy issue though, when it tries to get the package on server-side, it has an error of proxy (my enterprise proxy cannot access the ingress either...) whereas it should go through no_proxy.

I get error: 2024-05-31 13:49:24.162 [error] Error: Proxy connection ended before receiving CONNECT response at Socket.onend (/usr/lib/code-server/lib/vscode/node_modules/https-proxy-agent/dist/parse-proxy-response.js:32:20) at Socket.emit (node:events:529:35) at endReadableNT (node:internal/streams/readable:1368:12) at process.processTicksAndRejections (node:internal/process/task_queues:82:21)

code-asher commented 1 month ago

Glad the browser side is working now! But yeah sounds like we need that no_proxy fix for the server side to work.