Skip to content

fix(ext/node): fix dns.lookup result ordering#26264

Merged
kt3k merged 9 commits intodenoland:mainfrom
kt3k:fix-dns-resolt-order
Oct 16, 2024
Merged

fix(ext/node): fix dns.lookup result ordering#26264
kt3k merged 9 commits intodenoland:mainfrom
kt3k:fix-dns-resolt-order

Conversation

@kt3k
Copy link
Copy Markdown
Contributor

@kt3k kt3k commented Oct 15, 2024

partially unblocks #25470

This PR aligns the resolution of localhost hostname to Node.js behavior.

In Node.js dns.lookup("localhost", (_, addr) => console.log(addr)) prints ipv6 address ::1, but it prints ipv4 address 127.0.0.1 in Deno. That difference causes some errors in the work of enabling createConnection option in http.request (#25470). This PR fixes the issue by aligning dns.lookup behavior to Node.js.

This PR also changes the following behaviors (resolving TODOs):

  • http.createServer now listens on ipv6 address [::] by default on linux/mac
  • net.createServer now listens on ipv6 address [::] by default on linux/mac

These changes are also alignments to Node.js behaviors.

ref: nodejs/node#39987

@kt3k kt3k added the ci-draft Run the CI on draft PRs. label Oct 15, 2024
@kt3k kt3k force-pushed the fix-dns-resolt-order branch from 0814e2e to 19f4385 Compare October 15, 2024 08:37
@kt3k kt3k force-pushed the fix-dns-resolt-order branch from a0d2ced to d65fee7 Compare October 16, 2024 05:10
@kt3k kt3k force-pushed the fix-dns-resolt-order branch from e51a8d1 to 9257b70 Compare October 16, 2024 06:51
@kt3k kt3k marked this pull request as ready for review October 16, 2024 08:21
Comment thread tests/unit_node/http_test.ts Outdated
res.end();
});
server.listen(async () => {
server.listen({ host: "0.0.0.0" }, async () => {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we remove the host and update the request instead to make sure ipv6 is working as expected?

Copy link
Copy Markdown
Contributor Author

@kt3k kt3k Oct 16, 2024

Choose a reason for hiding this comment

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

Sure. In that case we need to update assertion part instead, as server.listen (without host specified) listens on ipv6 (::1) on unix and ipv4 (0.0.0.0) on windows (I think those are the expected behaviors). See 7def448

Copy link
Copy Markdown
Contributor

@satyarohith satyarohith left a comment

Choose a reason for hiding this comment

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

LGTM

@kt3k kt3k merged commit d59599f into denoland:main Oct 16, 2024
@kt3k kt3k deleted the fix-dns-resolt-order branch October 16, 2024 11:58
Copy link
Copy Markdown
Member

@bartlomieju bartlomieju left a comment

Choose a reason for hiding this comment

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

LGTM!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci-draft Run the CI on draft PRs.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants