make-fetch-happen
make-fetch-happen copied to clipboard
[BUG] Does not work with ipv6 http_proxy
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
Might be solved by using hpagent proxy agent, https://github.com/npm/make-fetch-happen/issues/59#issuecomment-1221421694 is related.
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.