Skip to content

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

Description

@kt3k

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" }));

Activity

  1. added
    confirmed-bugIssues and PRs for confirmed bugs.
    dnsIssues and PRs related to the dns subsystem.
    on Oct 15, 2024
  2. targos commented on Oct 15, 2024

    @targos
    Member

    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;
    }

  3. added a commit that references this issue on Oct 15, 2024
  4. added a commit that references this issue on Oct 17, 2024
  5. added a commit that references this issue on Oct 19, 2024
  6. added a commit that references this issue on Nov 27, 2024
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

    confirmed-bugIssues and PRs for confirmed bugs.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