GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — order of getaddrinfo results not respected · Issue #6307 · nodejs/node

order of getaddrinfo results not respected #6307

New issue
Copy link
New issue
Copy link
Closed
Closed
order of getaddrinfo results not respected#6307
Copy link
Labels
dnsIssues and PRs related to the dns subsystem.

Description

@benschulz
benschulz
opened on Apr 20, 2016
Issue body actions
  • Version: v5.10.1
  • Platform: Linux archer 4.4.5-1-ARCH deps: update openssl to 1.0.1j #1 SMP PREEMPT Thu Mar 10 07:38:19 CET 2016 x86_64 GNU/Linux
  • Subsystem: dns/cares_wrap

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.

Reacted by treysis and DasSkelett

Activity

Next
  1. jasnell commented on Apr 20, 2016

    @jasnell
    jasnell
    on Apr 20, 2016
    Member
    More actions

    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

    Reacted by Ray Bellis, Christian, Tristan, Maurice Walker, treysis, Fernando van Loenhout, Miyuru, Paul-Louis Ageneau, Lukáš Kvídera, ronnyaa and 1 more
  2. addaleax commented on Apr 20, 2016

    @addaleax
    addaleax
    on Apr 20, 2016
    Member
    More actions

    Is this still a problem when using the latest v6 release candidate (aka is this fixed by #6021)?

  3. addaleax
    added
    dnsIssues and PRs related to the dns subsystem.
    on Apr 20, 2016
  4. cjihrig commented on Apr 20, 2016

    @cjihrig
    cjihrig
    on Apr 20, 2016
    Contributor
    More actions

    The DNS hints aren't related to the reordering.

  5. cjihrig commented on Apr 20, 2016

    @cjihrig
    cjihrig
    on Apr 20, 2016
    Contributor
    More actions

    @bnoordhuis would the dns.ADDRCONFIG flag mitigate the problem?

  6. benschulz commented on Apr 20, 2016

    @benschulz
    benschulz
    on Apr 20, 2016
    Author
    More actions

    As I understand it, the proper place to configure preferences is via gai.conf.

    Snippet from my gai.conf:

    # precedence  <mask>   <value>
    #
    #    Defaults:
    #
    #precedence  ::1/128       50
    #precedence  ::/0          40
    #precedence  2002::/16     30
    #precedence ::/96          20
    #precedence ::ffff:0:0/96  10
    #
    #    For sites which prefer IPv4 connections change the last line to
    #
    #precedence ::ffff:0:0/96  100
    
  7. bnoordhuis commented on Apr 20, 2016

    @bnoordhuis
    bnoordhuis
    on Apr 20, 2016
    Member
    More actions

    would the dns.ADDRCONFIG flag mitigate the problem?

    Only partially. AI_ADDRCONFIG means 'return AAAA entries only when there is a configured IPv6 interface' but the presence of such an interface doesn't say anything about IPv6 traffic actually being routable. (That's true for IPv4 as well, of course; my point is that AI_ADDRCONFIG isn't a fix per se.)

    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.

    Reacted by Marco Davids and treysis
  8. jasnell commented on Apr 22, 2016

    @jasnell
    jasnell
    on Apr 22, 2016
    Member
    More actions

    There are likely two things that can happen here:

    1. We can improve the documentation to indicate why the results are ordered the way they are, and
    2. We can add an option that would tell the impl not to re-order the output. The current default behavior would remain.
  9. benschulz commented on Apr 25, 2016

    @benschulz
    benschulz
    on Apr 25, 2016
    Author
    More actions

    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.

    Reacted by treysis
  10. igalic commented on Dec 23, 2016

    @igalic
    igalic
    on Dec 23, 2016
    More actions

    from what i gather, this is possibly the source of my issue with npm install failing (a possible regression of npm/npm#6857)

    This time i'm running alpine (hence, muslc) under docker, again, IPv6-only network.

    ~ # node -e "dns.lookup('registry.npmjs.org', (...args) => console.log(args))"
    [ null, '151.101.112.162', 4 ]
    ~ # 
    

    note that musl implements rfc 3484/6724.

    this works fine in ruby, btw:

    # pry -r 'open-uri'
    [1] pry(main)> open("https://registry.npmjs.org/")
    => #<StringIO:0x0055ecc25d4fd0
     @base_uri=#<URI::HTTPS https://registry.npmjs.org/>,
     @meta=
      {"server"=>"CouchDB/1.5.0 (Erlang OTP/R16B03)",
       "content-type"=>"application/json",
       "cache-control"=>"max-age=300",
       "content-length"=>"194",
       "accept-ranges"=>"bytes",
    …etc…
    

    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 {};
       }
    Reacted by Miyuru
  11. benschulz commented on Dec 27, 2016

    @benschulz
    benschulz
    on Dec 27, 2016
    Author
    More actions

    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.

    Reacted by treysis
  12. sam-github commented on Dec 29, 2016

    @sam-github
    sam-github
    on Dec 29, 2016
    Contributor
    More actions

    Happy Eyeballs - for those who haven't heard the term

    Reacted by Refael Ackermann, Anton Rudeshko, marka63, Christian, Xavier Ruiz and Dan G
  13. igalic commented on Feb 3, 2017

    @igalic
    igalic
    on Feb 3, 2017
    More actions

    every month or two, i try a fresh major release of nodejs, only to find this issue is still there.

    (@jasnell commented on 22 Apr 2016) There are likely two things that can happen here:

    • We can improve the documentation to indicate why the results are ordered the way they are, and
    • We can add an option that would tell the impl not to re-order the output. The current default behavior would remain.

    i highly agree with @benschulz here:

    (@benschulz commented on 25 Apr 2016 • edited) 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.

    and believe that #4693 is the correct way forward — in 7.x+

    Reacted by Marco Davids
  14. Trott commented on Jul 16, 2017

    @Trott
    Trott
    on Jul 16, 2017
    Member
    More actions

    Should this remain open? (I'm guessing the answer is "yes" but would be happy to find out I'm wrong.)

  15. benschulz commented on Jul 16, 2017

    @benschulz
    benschulz
    on Jul 16, 2017
    Author
    More actions

    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.
    Fermi estimate: Two people have raised the issue; if we conservatively posit that .1‒1% of those affected manage to figure out the root cause and find this report, it'd be around 200‒2000 people affected in total.

    Hope that helps. :P

    Edit: Added missing "affected" qualifier. =)

    Reacted by Refael Ackermann, Anton Rudeshko, treysis and ronnyaa
  16. 77 remaining items

  17. zwhitchcox commented on Sep 26, 2021

    @zwhitchcox
    zwhitchcox
    on Sep 26, 2021
    More actions

    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!

    Reacted by Émilien (perso) and Marco Davids
  18. zwhitchcox commented on Oct 1, 2021

    @zwhitchcox
    zwhitchcox
    on Oct 1, 2021
    More actions

    Ok, I have created another repo which implements "happy eyeballs" and will patch the http(s).Agents to default to the happy eyeballs algorithm:

    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 createConnection calls to use happy eyeballs.

    I will be making a PR to NodeJS core as well.

    Reacted by Émilien (perso), Marco Davids and Jay Stewart
    Reacted by treysis and Arber X
    Reacted by treysis and Dan G
  19. telmich commented on Oct 1, 2021

    @telmich
    telmich
    on Oct 1, 2021
    More actions

    That is amazing to see, thanks a lot, @zwhitchcox!

    Reacted by Zane Hitchcox, Émilien (perso), Marco Davids and Suraj
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    dnsIssues and PRs related to the dns subsystem.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402775 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.