Skip to content
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: ipv4first doesn't seem to have effect in dns.lookup? #55391

Closed
kt3k opened this issue Oct 15, 2024 · 1 comment · Fixed by #55392
Closed

order: ipv4first doesn't seem to have effect in dns.lookup? #55391

kt3k opened this issue Oct 15, 2024 · 1 comment · Fixed by #55392
Labels
confirmed-bug Issues with confirmed bugs. dns Issues and PRs related to the dns subsystem.

Comments

@kt3k
Copy link
Contributor

kt3k commented Oct 15, 2024

Version

22.7.0

Platform

Darwin 23.6.0 Darwin Kernel Version 23.6.0: Mon Jul 29 21:14:21 PDT 2024; root:xnu-10063.141.2~1/RELEASE_ARM64_T8103 arm64

Subsystem

dns

What steps will reproduce the bug?

Run:

import dns from "node:dns";
dns.lookup("localhost", { all: true, order: "ipv4first" }, console.log);

How often does it reproduce? Is there a required condition?

Always

What is the expected behavior? Why is that the expected behavior?

The script prints:

null [ { address: '127.0.0.1', family: 4 }, { address: '::1', family: 6 } ]

What do you see instead?

The script prints:

null [ { address: '::1', family: 6 }, { address: '127.0.0.1', family: 4 } ]

Additional information

The issue doesn't happen with dns.promises.lookup. The below script prints ipv4 address first:

import dns from "node:dns";
console.log(await dns.promises.lookup("localhost", { all:true, order: "ipv4first" }));
@targos targos added confirmed-bug Issues with confirmed bugs. dns Issues and PRs related to the dns subsystem. labels Oct 15, 2024
@targos
Copy link
Member

targos commented Oct 15, 2024

There's an obvious bug here:

node/lib/dns.js

Lines 194 to 197 in 51d8146

if (options?.order != null) {
validateOneOf(options.order, 'options.order', ['ipv4first', 'ipv6first', 'verbatim']);
dnsOrder = options.dnsOrder;
}

lpinca added a commit to lpinca/node that referenced this issue Oct 15, 2024
aduh95 pushed a commit that referenced this issue Oct 19, 2024
Fixes: #55391
PR-URL: #55392
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Tim Perry <pimterry@gmail.com>
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Feng Yu <F3n67u@outlook.com>
Reviewed-By: Jake Yuesong Li <jake.yuesong@gmail.com>
louwers pushed a commit to louwers/node that referenced this issue Nov 2, 2024
Fixes: nodejs#55391
PR-URL: nodejs#55392
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Tim Perry <pimterry@gmail.com>
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Feng Yu <F3n67u@outlook.com>
Reviewed-By: Jake Yuesong Li <jake.yuesong@gmail.com>
tpoisseau pushed a commit to tpoisseau/node that referenced this issue Nov 21, 2024
Fixes: nodejs#55391
PR-URL: nodejs#55392
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Tim Perry <pimterry@gmail.com>
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Feng Yu <F3n67u@outlook.com>
Reviewed-By: Jake Yuesong Li <jake.yuesong@gmail.com>
ruyadorno pushed a commit that referenced this issue Nov 27, 2024
Fixes: #55391
PR-URL: #55392
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Tim Perry <pimterry@gmail.com>
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Feng Yu <F3n67u@outlook.com>
Reviewed-By: Jake Yuesong Li <jake.yuesong@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
confirmed-bug Issues with confirmed bugs. dns Issues and PRs related to the dns subsystem.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants