question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Internal proxy server doesn't work if http proxy is set

See original GitHub issue

Internal code-server’s proxy for accessing services doesn’t work if http proxy is configured.

Test case:

  1. create vscode extension that runs http server that returns “ok” on /status route, bind the server to port 3000
  2. install the extension into code-server
  3. 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)
  4. curl http://localhost:3000/status
  5. => you get OK response
  6. now (assuming code-server runs on port 7777) via proxy: curl http://localhost:7777/proxy/3000/status
  7. => 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() {
...```

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:2
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
jsjoeiocommented, Aug 23, 2021

I can’t promise when we will get to this, but I’ll move it to “On Deck” meaning it’s ready to be placed in an upcoming version milestone.

1reaction
Chilippcommented, Aug 20, 2021

hey! thanks a lot @mfukala for this workaround! it would have taken me hours to come up with such a solution. I can confirm that setting an environment variable like NO_PROXY=example.com, <some-other-domains> works well!

Are there any ideas how to solve this? Or is this part of the investigation in #3841?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Internal proxy server doesn't work if http proxy is set #3662
Internal code-server's proxy for accessing services doesn't work if http proxy is configured. Test case: create vscode extension that runs ...
Read more >
How to Fix “There Is Something Wrong With the Proxy Server ...
1. Check if You Have a Stable Internet Connection · 2. Restore Your Proxy Server to Its Default Settings · 3. Disabling Your...
Read more >
Fix: No Internet, There Is Something Wrong With Proxy Server
1. Check your internet connection or proxy settings · Click on the Start menu, type Internet Options, and then open it from the...
Read more >
How to Fix Unable to Connect to the Proxy Server | VSS Guide
If you are still unable to connect to proxy server, you can clear the browser cache. Clearing browser cache will remove corrupt scripts...
Read more >
Internal web server not accessible through my organisation's ...
If the web server is only internal, and the proxy server just allow access to internet sites, then you cannot configure the web...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found