-
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
src: cares_wrap: only loop through once on lookup #4693
Conversation
The results will already be sorted based on the implementation of getaddrinfo(). There is no need to loop through the returned addresses twice (once for IPv4, once for IPv6). We should return them in the order in which they already are.
Anyone know the original reason for doing this? Looks like it happened way back in 194511f. |
The original reason was to make sure that it won't break on IPv4-only machines. We don't do happy eyeballs in node, so it was pretty important at that time, I guess? cc @bnoordhuis |
As of it, I am not sure if we should fix it, or leave it as it is. |
What Fedor said, node prefers IPv4 over IPv6 to avoid breakage when there is no IPv6 connectivity. We don't do happy eyeballs. If you change the order, that would have to change. That's a big can of worms. |
Ok, thanks for the explanation. Is us implementing happy eyeballs something we should explore? Or is that too big of a breaking change? Or is it just not worth it? |
I don't know how others feel but I'm of the opinion that happy eyeballs is a shameful hack with too much potential for confusing, seemingly random behavior. |
Seems like it would make bugs more difficult to reproduce and fix. |
Ok, that works for me. |
unfortunately, the consequence is that it breaks IPv6 only machines. |
Any news? |
Referring to the comment of @igalic : Yes, exactly that is happening for me now. I have a nodejs program on a ipv6 only machine and it fails when trying to connect to outside servers because ipv4 is given preference, but no connection can be established. Is there any way to work around that problem? |
You can pass |
In theory I could, but the problem is actually hidden a few layers deep within the software I am trying to run. The actual problem seems to be caused within the package nodemailer when trying to send an email using SMTP. Nodemailer is used by the mailing list tool mailtrain, which is running inside a docker container. I could of course now dive into the source code of nodemailer, try to isolate the line which is causing the problem, then extract & fix the corresponding file and mount it as an overlay into the docker container, but that really seems like an overly complex solution :/ |
Maybe the problem is even higher? I don't recall IPv4-only machines even doing AAAA-lookups. So why is an IPv6-only machine doing A-lookups? Should this be addressed in the Linux kernel? And for short term solution until NodeJS introduces happy eyeballs: there should be two packages made available, one with IPv4-preference, and one with IPv6-preference. This way it satisfies both. |
The results will already be sorted based on the implementation of
getaddrinfo(). There is no need to loop through the returned addresses
twice (once for IPv4, once for IPv6). We should return them in the
order in which they already are.
References:
This may need to be marked as semver-major