Skip to content

Comments

fix(node:dns): fix three bugs in dns lookup and resolver#6128

Merged
anonrig merged 2 commits intomainfrom
fix/node-dns-bugs
Feb 21, 2026
Merged

fix(node:dns): fix three bugs in dns lookup and resolver#6128
anonrig merged 2 commits intomainfrom
fix/node-dns-bugs

Conversation

@dknecht
Copy link
Member

@dknecht dknecht commented Feb 21, 2026

Summary

Fixes three bugs in the node:dns implementation:

  • IPv6 family mismatch: dns.lookup() with all: true and family: 0 returned IPv6 (AAAA) addresses with family: 4 instead of family: 6. Both the type annotation and runtime value were wrong — copy-paste from the IPv4 block above.

  • Default lookup only queried AAAA: dns.lookup() with default family: 0 and all: false used family === 4 ? 'A' : 'AAAA', which fell through to AAAA-only queries. This meant dns.lookup('example.com', callback) would fail for IPv4-only hosts. Now queries both A and AAAA and returns the first result based on dnsOrder.

  • Resolver.resolvePtr typo: The promises Resolver class had esolvePtr (missing leading r), making resolver.resolvePtr() throw at runtime.

*** AI CREATED ***

- Fix IPv6 addresses returned with family:4 instead of family:6 in
  dns.lookup() with all:true and family:0
- Fix dns.lookup() with default family:0 only querying AAAA records,
  now queries both A and AAAA and returns based on dnsOrder
- Fix Resolver.resolvePtr typo (was 'esolvePtr') in promises API
@dknecht dknecht requested review from a team as code owners February 21, 2026 14:26
@github-actions
Copy link

github-actions bot commented Feb 21, 2026

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@dknecht
Copy link
Member Author

dknecht commented Feb 21, 2026

I have read the CLA Document and I hereby sign the CLA

github-actions bot added a commit that referenced this pull request Feb 21, 2026
@codspeed-hq

This comment was marked as outdated.

@jasnell jasnell assigned anonrig and unassigned anonrig Feb 21, 2026
@jasnell jasnell requested a review from anonrig February 21, 2026 16:08
@jasnell
Copy link
Collaborator

jasnell commented Feb 21, 2026

Ideally this would also include additional tests.

@dknecht
Copy link
Member Author

dknecht commented Feb 21, 2026 via email

Copy link
Member

@anonrig anonrig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks. we can merge after some regression tests.

- lookup all:true family:0 must return family:6 for IPv6 addresses
- lookup default family:0 all:false must resolve IPv4-only hosts
- Resolver.resolvePtr must exist (was typo 'esolvePtr')
@anonrig anonrig merged commit 5356403 into main Feb 21, 2026
22 checks passed
@anonrig anonrig deleted the fix/node-dns-bugs branch February 21, 2026 23:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants