make-fetch-happen icon indicating copy to clipboard operation
make-fetch-happen copied to clipboard

[BUG] Does not work with ipv6 http_proxy

Open t-kawatsu opened this issue 3 years ago • 1 comments

What / Why

fetch request does not work with under following conditions

  • proxy is specified with http(s)_proxy environments
  • proxy url is ipv6 and contains brackets on it

like below: http_proxy='http://[2001:0db8:bd05:01d2:288a:1fc0:0001:10ee]:3128'

Where

https://github.com/npm/make-fetch-happen/blob/main/lib/agent.js#L18

How

$ export http_proxy='http://[2001:0db8:bd05:01d2:288a:1fc0:0001:10ee]:3128'
$ npm install

Current Behavior

npm install ends up with failure with following error

npm ERR! code ENOTFOUND
npm ERR! syscall getaddrinfo
npm ERR! errno ENOTFOUND
npm ERR! network request to https://registry.npmjs.org/lodash failed, reason: getaddrinfo ENOTFOUND [2001:0db8:bd05:01d2:288a:1fc0:0001:10ee]
npm ERR! network This is a problem related to network connectivity.
npm ERR! network In most cases you are behind a proxy or have bad network settings.
npm ERR! network
npm ERR! network If you are behind a proxy, please make sure that the
npm ERR! network 'proxy' config is set properly.  See: 'npm help config'

Expected Behavior

can install package with proxy url which contains brackets

t-kawatsu avatar Jan 05 '22 08:01 t-kawatsu

Might be solved by using hpagent proxy agent, https://github.com/npm/make-fetch-happen/issues/59#issuecomment-1221421694 is related.

silverwind avatar Sep 16 '22 11:09 silverwind

This should be fixed by the latest version of @npmcli/[email protected]. That package now handles all the socket connections and can be set to use family: 4 or family: 6. The only outstanding bug is that these will not be passed to socks-proxy-agent until that is supported there: https://github.com/TooTallNate/proxy-agents/pull/241

If you are still seeing issues, please open a new issue (or i can transfer this one and reopen it) over at https://github.com/npm/agent/issues/new/choose.

lukekarrys avatar Aug 30 '23 17:08 lukekarrys