undici
undici copied to clipboard
Try all available addresses when connecting to localhost (127.0.0.1 and ::1)
In node v17 (specifically https://github.com/nodejs/node/pull/39987), we switched the default ordering of dns entries to follow what the OS is providing us vs reordering to put IPv4 addresses always first. This creates quite a few issues for folks as some tools only listen to 127.0.0.1
and not ::1
.
I think we should try multiple addresses when dealing with localhost when establishing a new connection.
Originaklly reported as https://github.com/nodejs/undici/issues/1248.
I don't quite understand what localhost has to do with this issue? In #1248 no localhost was involved.
This issue is based on this comment: https://github.com/nodejs/undici/issues/1248#issuecomment-1054467140. There is something we could improve with localhost
. As for your problem, we need a repro (feel free to add it to the original issue).
FWIW I'm getting this when running mockAgent.disableNetConnect()
with fetch
. Might be a different issue (including an "I'm holding it wrong" issue), but wanted to let y'all know just in case. Here's my monorepo (core is the module that matters here) at the commit that I'm consistently experiencing this issue with.
I think this should work as a way to get the stack traces quickly: git clone https://github.com/cutenode/nodevu && cd nodevu && git checkout 38d46bee90cd0d20762257f9aa6c99ef9ed341ae && npm install && npm run test -w core
Note: this is better solved in nodejs core. https://github.com/nodejs/node/issues/41625
Hi @mcollina, seems like this haven't been assigned/implemented yet?
would this fix https://github.com/nodejs/node/pull/44731 solve this issue?
Yes, we'd need to enable that setting once it lands.
Should we enable it by default? Agents should be able to set this option already, under connect
in options.