-
Notifications
You must be signed in to change notification settings - Fork 30k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
net: add autoSelectFamily option #44731
Conversation
Review requested:
|
5a35dae
to
8e79310
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please add a test for HTTPs too?
8e79310
to
c301ed9
Compare
@nodejs/tsc this is a notable change that we should land before v18 goes LTS. We have seen quite a few reports of bugs due to improper configuration of IPv6, making #41625 a necessity. For example, Docker on Mac only exposes ports on the IPv4 address, making all connections to |
No comment (yet at least) one way or the other on the implementation, but +1000 to implementing happy eyeballs in Node.js. |
The two new tests fail for me (Linux x64) and also in GitHub actions.
|
Acknowledged! |
Same goes for me as well. |
617860b
to
b1c7de5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add test for dnsPromises.Resolver
as well?
@nodejs/tsc
|
I'm going to rebase and force push to at least get the tarball job working. |
b1c7de5
to
25f2336
Compare
My case is that we should make it enabled by default. This causes so many headaches to newbie developers that know little of IPv4 vs IPv6 and why localhost is two IPs. We should make this change before v18 goes LTS. |
Upgrade grunt-contrib-internal from 6 to 8, which updates CI from Node 10,12,14 to Node 14,16,18,20. Fix default connect() hostname to work on Node 18+, where otherwise CI fails as follows: > Running "nodeunit:tests" (nodeunit) task > Testing connect_test.jsFatal error: connect ECONNREFUSED ::1:8000 > Error: connect ECONNREFUSED ::1:8000 > at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1494:16) Previously, grunt-contrib-connect was passing empty string or null down to `connect(,hostname)` to leave the default implicitly handled by `connect` and Node's built-in `http.Server` class. Then, later, it was doing a fallback to `0.0.0.0` but this only affected the CLI output text, not the value passed to `connect()`. Node 17+ changed per nodejs/node#40702 to prefer IPv6 loopback when available (`::`) instead of IPv4 loopback (`0.0.0.0`), unless `0.0.0.0` is explicitly passed. This was fixed in Node 20, with `http.get` underlying `net` TCP module implementing "Happy Eyeballs" (same as browsers and curl) which basically means trying both IPv6 and IPv4. nodejs/node#44731 The workaround is to call `dns.setDefaultResultOrder('ipv4first')` which ensures that the first try is over IPv4 instead of IPv6.
Upgrade grunt-contrib-internal from 6 to 8, which updates CI from Node 10,12,14 to Node 14,16,18,20. Fix default connect() hostname to work on Node 18+, where otherwise CI fails as follows: > Running "nodeunit:tests" (nodeunit) task > Testing connect_test.jsFatal error: connect ECONNREFUSED ::1:8000 > Error: connect ECONNREFUSED ::1:8000 > at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1494:16) Previously, grunt-contrib-connect was passing empty string or null down to `connect(,hostname)` to leave the default implicitly handled by `connect` and Node's built-in `http.Server` class. Then, later, it was doing a fallback to `0.0.0.0` but this only affected the CLI output text, not the value passed to `connect()`. Node 17+ changed per nodejs/node#40702 to prefer IPv6 loopback when available (`::`) instead of IPv4 loopback (`0.0.0.0`), unless `0.0.0.0` is explicitly passed. This was fixed in Node 20, with `http.get` underlying `net` TCP module implementing "Happy Eyeballs" (same as browsers and curl) which basically means trying both IPv6 and IPv4. nodejs/node#44731 The workaround is to call `dns.setDefaultResultOrder('ipv4first')` which ensures that the first try is over IPv4 instead of IPv6.
Upgrade grunt-contrib-internal from 6 to 8, which updates CI from Node 10,12,14 to Node 14,16,18,20. Fix default connect() hostname to work on Node 18+, where otherwise CI fails as follows: > Running "nodeunit:tests" (nodeunit) task > Testing connect_test.jsFatal error: connect ECONNREFUSED ::1:8000 > Error: connect ECONNREFUSED ::1:8000 > at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1494:16) Previously, grunt-contrib-connect was passing empty string or null down to `connect(,hostname)` to leave the default implicitly handled by `connect` and Node's built-in `http.Server` class. Then, later, it was doing a fallback to `0.0.0.0` but this only affected the CLI output text, not the value passed to `connect()`. Node 17+ changed per nodejs/node#40702 to prefer IPv6 loopback when available (`::`) instead of IPv4 loopback (`0.0.0.0`), unless `0.0.0.0` is explicitly passed. This was fixed in Node 20, with `http.get` underlying `net` TCP module implementing "Happy Eyeballs" (same as browsers and curl) which basically means trying both IPv6 and IPv4. nodejs/node#44731 The workaround is to call `dns.setDefaultResultOrder('ipv4first')` which ensures that the first try is over IPv4 instead of IPv6.
Upgrade grunt-contrib-internal from 6 to 8, which updates CI from Node 10,12,14 to Node 14,16,18,20. Fix default connect() hostname to work on Node 18+, where otherwise CI fails as follows: > Running "nodeunit:tests" (nodeunit) task > Testing connect_test.jsFatal error: connect ECONNREFUSED ::1:8000 > Error: connect ECONNREFUSED ::1:8000 > at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1494:16) Previously, grunt-contrib-connect was passing empty string or null down to `connect(,hostname)` to leave the default implicitly handled by `connect` and Node's built-in `http.Server` class. Then, later, it was doing a fallback to `0.0.0.0` but this only affected the CLI output text, not the value passed to `connect()`. Node 17+ changed per nodejs/node#40702 to prefer IPv6 loopback when available (`::`) instead of IPv4 loopback (`0.0.0.0`), unless `0.0.0.0` is explicitly passed. This was fixed in Node 20, with `http.get` underlying `net` TCP module implementing "Happy Eyeballs" (same as browsers and curl) which basically means trying both IPv6 and IPv4. nodejs/node#44731 The workaround is to call `dns.setDefaultResultOrder('ipv4first')` which ensures that the first try is over IPv4 instead of IPv6.
@@ -1630,6 +1647,7 @@ net.isIPv6('fhqwhgads'); // returns false | |||
|
|||
[IPC]: #ipc-support | |||
[Identifying paths for IPC connections]: #identifying-paths-for-ipc-connections | |||
[RFC 8305]: https://www.rfc-editor.org/rfc/rfc8305.txt |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
@@ -1630,6 +1647,7 @@ net.isIPv6('fhqwhgads'); // returns false | |||
|
|||
[IPC]: #ipc-support | |||
[Identifying paths for IPC connections]: #identifying-paths-for-ipc-connections | |||
[RFC 8305]: https://www.rfc-editor.org/rfc/rfc8305.txt |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
This commit upgrades Node.js version to v20.x in CI/CD environment. Previously used Node 18.x is moving towards end-of-life, with a planned date of 2025-04-30. In contrast, Node 20.x has been offering long-term support (LTS) since 2023-10-24. This makes Node 20.x a stable and recommended version for production environments. This commit also configures `actions/setup-node` with the `check-latest` flag to always use the latest Node 20.x version, keeping CI/CD setup up-to-date with minimal maintenance. Details: - actions/setup-node#165 - actions/setup-node#160 Using Node 20.x in CI/CD environments provides better compatibility with Electron v29.0 which moves to Node 20.x. Details: - electron/electron#40343 This upgrade improves network connection handling in CI/CD pipelines (where issues occur due to GitHub runners not supporting IPv6). Details: - actions/runner#3138 - actions/runner-images#668 - actions/runner#3213 - actions/runner-images#9540 Node 20.x adopts the Happy Eyeballs algorithm for improved IPv6 connectivity. - nodejs/node#40702 - nodejs/node#41625 - nodejs/node#44731 This mitigates issues like `UND_ERR_CONNECT_TIMEOUT` and localhost DNS resolution in CI/CD environments: Details: - nodejs/node#40537 - actions/runner#3213 - actions/runner-images#9540 Node 20 introduces `setDefaultAutoSelectFamily`, a global function from Node 19.4.0, enabling better IPv4 support, especially in environments with limited or problematic IPv6 support. Details: - nodejs/node#45777 Node 20.x defaults to the new `autoSelectFamily`, improving network connection reliability in GitHub runners lacking full IPv6 support. Details: - nodejs/node#46790
This commit upgrades Node.js version to v20.x in CI/CD environment. Previously used Node 18.x is moving towards end-of-life, with a planned date of 2025-04-30. In contrast, Node 20.x has been offering long-term support (LTS) since 2023-10-24. This makes Node 20.x a stable and recommended version for production environments. This commit also configures `actions/setup-node` with the `check-latest` flag to always use the latest Node 20.x version, keeping CI/CD setup up-to-date with minimal maintenance. Details: - actions/setup-node#165 - actions/setup-node#160 Using Node 20.x in CI/CD environments provides better compatibility with Electron v29.0 which moves to Node 20.x. Details: - electron/electron#40343 This upgrade improves network connection handling in CI/CD pipelines (where issues occur due to GitHub runners not supporting IPv6). Details: - actions/runner#3138 - actions/runner-images#668 - actions/runner#3213 - actions/runner-images#9540 Node 20.x adopts the Happy Eyeballs algorithm for improved IPv6 connectivity. - nodejs/node#40702 - nodejs/node#41625 - nodejs/node#44731 This mitigates issues like `UND_ERR_CONNECT_TIMEOUT` and localhost DNS resolution in CI/CD environments: Details: - nodejs/node#40537 - actions/runner#3213 - actions/runner-images#9540 Node 20 introduces `setDefaultAutoSelectFamily`, a global function from Node 19.4.0, enabling better IPv4 support, especially in environments with limited or problematic IPv6 support. Details: - nodejs/node#45777 Node 20.x defaults to the new `autoSelectFamily`, improving network connection reliability in GitHub runners lacking full IPv6 support. Details: - nodejs/node#46790
This PR loosely implements section 5 of RFC 8305 (Happy Eyeballs algorithm).
A new option
autoSelectFamily
is added tonet.connect
.When set to a positive number (or
true
), the lookup phase will keep all records by settingall=true
.A connection attempt will be tried to all AAAA and A records (alternating families), in sequence, giving each connection
autoSelectFamily
milliseconds to be established.Errors are raised only if no connection succeeded.
Fixes #41625.