microsoft / vscode-generator-code

Visual Studio Code extension generator
Other
1.3k stars 222 forks source link

Proxy configuration is ignored #404

Closed HispidaBytes closed 1 year ago

HispidaBytes commented 1 year ago

Hi,

I'm having an issue with this generator on a Windows machine inside a corporate network. The generator is showing the following error:

Unable to evaluate the latest vscode version: Error:  {
  responseText: 'Unable to connect to https://update.code.visualstudio.com/api/releases/stable through a proxy. Error: connect ETIMEDOUT 20.105.224.24:443',
  body: <Buffer >,
  status: 404,
  headers: {}
}

The proxy is correctly configured by using the HTTP_PROXY and HTTPS_PROXY environment variables. Upon further investigation it does seem that the proxy server is not actually used when doing a HTTP connect to https://update.code.visualstudio.com. A procmon log is showing that the node.exe executable is trying to do an HTTP connect directly on the website IP address instead of relying on the proxy server.

If I try to run the following command on powershell I do get a valid result: Invoke-WebRequest https://update.code.visualstudio.com/api/releases/stable

That URL is also accessible via a browser configured with the same proxy server.

aeschli commented 1 year ago

I learned that the yo scaffolding tool uses a global HTTP agent: https://www.npmjs.com/package/global-agent that replaces the one we use in the VSCode generator (which would read HTTPS_PROXY)

It uses different environment variables: https://www.npmjs.com/package/global-agent#environment-variables

So you need to set GLOBAR_AGENT_HTTPS_PROXY=..

Or stick with HTTPS_PROXY and disable the global agent: GLOBAL_AGENT_FORCE_GLOBAL_AGENT=false

aeschli commented 1 year ago

I learned that the yo scaffolding tool uses a global HTTP agent: https://www.npmjs.com/package/global-agent that replaces the one we use in the VSCode generator (which would read HTTPS_PROXY)

It uses different environment variables: https://www.npmjs.com/package/global-agent#environment-variables

So you need to set GLOBAR_AGENT_HTTPS_PROXY=..

Or stick with HTTPS_PROXY and disable the global agent: GLOBAL_AGENT_FORCE_GLOBAL_AGENT=false

Suudy commented 1 year ago

This was helpful!

Alternatively, one can set GLOBAL_AGENT_ENVIRONMENT_VARIABLE_NAMESPACE to a blank value, which will pull in the system HTTP_PROXY and HTTPS_PROXY variables.