Skip to content

dns.setServers.apply triggers SIGABRT when passed an address with port 0 #65006

Description

@davidebombelli

Version

v26.5.1

Platform

Linux bombe-mint 6.8.0-136-generic #136-Ubuntu SMP PREEMPT_DYNAMIC Wed Jul  1 21:53:05 UTC 2026 x86_64 x86_64 x86_64 GNU/Linux

Subsystem

No response

What steps will reproduce the bug?

Run the following code with node test.js:

const dns = require('node:dns');

const callArg = [[ '1.1.1.1:0' ]];

try {
    dns.setServers.apply(dns, callArg);
}
catch (e) {
    console.log(`Exception thrown: ${e} ${e.stack}`);
}

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

It reproduces reliably every time that the above code is run.

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

The code should work without throwing any error.

What do you see instead?

  #  /usr/local/n/versions/node/26.5.1/bin/node[19657]: void node::cares_wrap::(anonymous namespace)::SetServers(const FunctionCallbackInfo<Value> &) at ../src/cares_wrap.cc:2164
  #  Assertion failed: portValue->Int32Value(env->context()).FromJust()

----- Native stack trace -----

 1: 0x81d228 node::Assert(node::AssertionInfo const&) [/usr/local/n/versions/node/26.5.1/bin/node]
 2: 0x8b550b  [/usr/local/n/versions/node/26.5.1/bin/node]
 3: 0x7a67bad8fae9 

----- JavaScript stack trace -----

1: [dns:resolver:setServers] (node:internal/dns/utils:162:38)
2: setServers (node:internal/dns/utils:154:30)
3: defaultResolverSetServers (node:dns:309:12)
4: /home/username/test.js:6:20
5: node:internal/modules/cjs/loader:1934:14
6: node:internal/modules/cjs/loader:2074:10
7: node:internal/modules/cjs/loader:1656:32
8: node:internal/modules/cjs/loader:1448:12
9: wrapModuleLoad (node:internal/modules/cjs/loader:261:19)
10: executeUserEntryPoint (node:internal/modules/run_main:154:5)


Aborted (core dumped)

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    confirmed-bugIssues with 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