-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
order of getaddrinfo results not respected #6307
Comments
As I understand it, without the reordering, ipv6 addresses could be the first entry, which would break anywhere that doesn't have an ipv6 stack. The current implementation is intentional in order to give preference to ipv4. /cc @bnoordhuis |
Is this still a problem when using the latest v6 release candidate (aka is this fixed by #6021)? |
The DNS hints aren't related to the reordering. |
@bnoordhuis would the |
As I understand it, the proper place to configure preferences is via gai.conf. Snippet from my gai.conf:
|
Only partially. We made the decision to prefer IPv4 over IPv6 three or four years ago when IPv6 support was much more spotty than it is today. It's something we can reconsider if the majority thinks it's a good idea. |
There are likely two things that can happen here:
|
This is clearly a violation of the principle of least astonishment and I don't see how adding documentation is going to help. Hardly anyone affected by this will be using the dns module directly. It took me half a day before realizing my issue was with the dns module. Since then I have put a workaround in place and am no longer affected. Still, I think you should slowly phase out this odd logic. IMHO, over time, keeping it will hurt more than it helps. |
from what i gather, this is possibly the source of my issue with This time i'm running alpine (hence, muslc) under docker, again, IPv6-only network.
note that musl implements rfc 3484/6724. this works fine in ruby, btw:
from what i gather, this can be fixed with: diff --git a/lib/dns.js b/lib/dns.js
index cbb994b8f2..c161a89a66 100644
--- a/lib/dns.js
+++ b/lib/dns.js
@@ -140,7 +140,7 @@ exports.lookup = function lookup(hostname, options, callback) {
if (all) {
callback(null, []);
} else {
- callback(null, null, family === 6 ? 6 : 4);
+ callback(null, null, family === 4 ? 4 : 6);
}
return {};
} |
That fix would default the family to 6 iff the caller isn't asking for all families. However, most of the time the caller should be asking for all families. Even if that was not the case, changing defaults is a mean thing to do to clients. Generally any caller should ask for all families and then try the results in-order. If the caller were to implement happy eyeballs they would ask for all and concurrently try the per-familiy subsequences in-order. IMHO the proper way to fix this is to apply #4693. Whether to happy eyeball or not is orthogonal. |
Happy Eyeballs - for those who haven't heard the term |
every month or two, i try a fresh major release of nodejs, only to find this issue is still there.
i highly agree with @benschulz here:
and believe that #4693 is the correct way forward — in 7.x+ |
Should this remain open? (I'm guessing the answer is "yes" but would be happy to find out I'm wrong.) |
This is your project and you are free to take it in any direction you please. If you think the status quo is good enough or even right, you should close the ticket. All I can tell you is that I had a really rough time with this. But that's just one data point, I imagine there are several more people affected. Hope that helps. :P Edit: Added missing "affected" qualifier. =) |
@bnoordhuis looking at your comments:
I understand that you're against implementing happy eyeballs, but not necessarily against just letting the results come back in their original order. Is your second comment saying that ceasing to modify the order will force us to implement happy eyeballs? I understand that this may be a massive breaking change, and thus a non-starter, but if it's possible to make that change we can at least consider it (even if it's just an option for now, and doesn't become the default till Node 18.x). |
Not exactly. Happy eyeballs is a transition mechanism. It's not needed in a world where IPv6 connectivity is good enough. Do we live in that world yet? Maybe, maybe not; not enough data. |
That's the part of the argument I don't understand. I set my system up to resolve names to IPv6 addresses and, if that yields no results, to IPv4 addresses. What's the issue? (I consider names with invalid |
A valid AAAA entry does not mean there is a network path to that machine. That was historically a big barrier to IPv6 adoption and is what happy eyeballs tries to address: try IPv6 and IPv4 in parallel and use whatever manages to establish a connection. |
So anyone affected has an IPv4 and an IPv6 address and their ISP is unable to route all IPv6 packets? Couldn't they do the reverse of what I do, i.e. prefer IPv4 over IPv6 at the OS rather than application level? I appreciate the time taken for the various comments, thank you. |
Yes, but that takes time and effort to set up. We want to avoid a situation where a node.js release breaks the out-of-the-box experience for a large group of users, especially when it might be difficult to debug for them. |
then, the best way forward, as mentioned numerous times in this issue, would be to implement happy eyes in a future version of node.js |
I don't see anyone in this thread suggesting implementing happy eyeballs in Node.js |
Not sure if this is the right bug, but IPv6 support seems to be seriously broken since 0.10... until and including v6.11.2. No version (also not 4.8.2 or 4.8.4) are capable of working in IPv6 only networks (as originally described in node-fetch/node-fetch#66). It seems that npm is only trying IPv4, where everything else works. This breaks various software building on top of node and will cause a variety of problems when bigger vendors like Apple will soon require IPv6 networks to function. Is there any chance that there will be a proper IPv6 support in nodejs in the near future? |
I am sorry, I actually meant to refer to npm/npm#6857 |
@telmich just for clarity, there is a separation of responsibility between |
@benschulz and @igalic will a configuration mechanism that will reorder/restore-the-order of |
env options or global config vars would work. the (often unknown (to an end-user)) layers of indirection are also why it takes so long for people to pup up here after having exhausted all other venues.
this behaviour of the software is really unintuitive. but then people finally get here (at least those that persisted thru all these steps) and find a bug where we're arguing whether in a world where we've run out of IPv4 addresses, we should support an IPv6 only setup. for over a year now. |
Switch the default from false (reorder the result so that IPv4 addresses come before IPv6 addresses) to true (return them exactly as the resolver sent them to us.) Fixes: nodejs#31566 Refs: nodejs#6307 Refs: nodejs#20710 Refs: nodejs#38099 Reissue of nodejs#31567 Reissue of nodejs#37681 Reissue of nodejs#37931
Switch the default from false (reorder the result so that IPv4 addresses come before IPv6 addresses) to true (return them exactly as the resolver sent them to us.) Fixes: #31566 Refs: #6307 Refs: #20710 Refs: #38099 Reissue of #31567 Reissue of #37681 Reissue of #37931 PR-URL: #39987 Refs: #6307 Refs: #20710 Refs: #38099 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michael Dawson <midawson@redhat.com>
Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com> PR-URL: #39987 Fixes: #31566 Refs: #6307 Refs: #20710 Refs: #38099 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michael Dawson <midawson@redhat.com>
Switch the default from `ipv4first` to `verbatim` (return them exactly as the resolver sent them to us). PR-URL: #39987 Fixes: #31566 Refs: #6307 Refs: #20710 Refs: #38099 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michael Dawson <midawson@redhat.com>
Switch the default from `ipv4first` to `verbatim` (return them exactly as the resolver sent them to us). PR-URL: #39987 Fixes: #31566 Refs: #6307 Refs: #20710 Refs: #38099 Co-authored-by: treysis <treysis@gmx.net> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michael Dawson <midawson@redhat.com>
For all interested parties, I have implemented happy eyeballs for my company, Balena, here: https://github.com/balena-io-modules/fetch The code is open source, so if anyone wants to adapt it to their needs, please feel free. If anyone would like me to make a PR to node with the code adapted for nodejs core, please let me know and how exactly it should be integrated. As IPv4 addresses are exhausted, this will be more and more of a problem, especially on mobile networks, and especially in developing countries with large populations. It's probably best to go ahead and prepare for it now if we can! |
Ok, I have created another repo which implements "happy eyeballs" and will patch the https://www.npmjs.com/package/happy-eyeballs With this package you can just add import 'happy-eyeballs/eye-patch' to the top of your file to default all I will be making a PR to NodeJS core as well. |
That is amazing to see, thanks a lot, @zwhitchcox! |
The results returned by
getaddrinfo
are reordered, giving preference to ipv4 addresses. The explanation given in #4693 seems unsatisfactory. Not implementing happy eyeballs is a reasonable design decision, of course, but why does that mean ipv4? It should mean taking the first entry. At the moment node is deliberately defying the system configuration.The text was updated successfully, but these errors were encountered: