-
Notifications
You must be signed in to change notification settings - Fork 6.2k
Closed as not planned
Labels
bugSomething isn't workingSomething isn't workingwaiting-for-infoWaiting for more information from submitterWaiting for more information from submitter
Milestone
Description
Internal code-server's proxy for accessing services doesn't work if http proxy is configured.
Test case:
- create vscode extension that runs http server that returns "ok" on /status route, bind the server to port 3000
- install the extension into code-server
- run code-server --auth=none -vvv (so curl examples below work w/ auth) from an environment where http_proxy, https_proxy and no_proxy is set (ensure address 0.0.0.0 is in no_proxy)
- curl http://localhost:3000/status
- => you get OK response
- now (assuming code-server runs on port 7777) via proxy: curl http://localhost:7777/proxy/3000/status
- => you get 500 response with message "Maximum callstack exceeded"
Following code calls itself in an endless loop:
at ProxyAgent.callback (/usr/local/Cellar/code-server/3.10.2/libexec/node_modules/proxy-agent/index.js:215:11)
at /usr/local/Cellar/code-server/3.10.2/libexec/node_modules/agent-base/dist/src/promisify.js:6:16
at new Promise (<anonymous>)
at ProxyAgent.promisifiedCallback (/usr/local/Cellar/code-server/3.10.2/libexec/node_modules/agent-base/dist/src/promisify.js:5:16)
at ProxyAgent.addRequest (/usr/local/Cellar/code-server/3.10.2/libexec/node_modules/agent-base/dist/src/index.js:187:38)
at ProxyAgent.callback (/usr/local/Cellar/code-server/3.10.2/libexec/node_modules/proxy-agent/index.js:215:11)
at /usr/local/Cellar/code-server/3.10.2/libexec/node_modules/agent-base/dist/src/promisify.js:6:16
at new Promise (<anonymous>)
at ProxyAgent.promisifiedCallback (/usr/local/Cellar/code-server/3.10.2/libexec/node_modules/agent-base/dist/src/promisify.js:5:16)
The reason is monkey patching of http(s).globalAgent done in proxy_agent.js
.
The code in node_modules/proxy-agent/index.js
(#httpOrHttps) is supposed to return bare http(s).globalAgent in case the processed http request is not supposed to be proxied but it returns the monkey patched instance which is the initiator of the call.
A very ugly workaround is to ensure proxy_agent#shouldEnableProxy returns false by adding "example.com" to no_proxy as the code comment suggests :-)
// But that's drastically unlikely.
function shouldEnableProxy() {
...```
Chilippjsjoeio
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingwaiting-for-infoWaiting for more information from submitterWaiting for more information from submitter