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

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

Merged
merged 9 commits into from
Oct 16, 2024

Conversation

kt3k
Copy link
Member

@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 marked this pull request as ready for review October 16, 2024 08:21
@@ -314,7 +314,7 @@ Deno.test("[node/http] IncomingRequest socket has remoteAddress + remotePort", a
remotePort = req.socket.remotePort;
res.end();
});
server.listen(async () => {
server.listen({ host: "0.0.0.0" }, async () => {
Copy link
Member

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
Member 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
Member

@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
17 checks passed
@kt3k kt3k deleted the fix-dns-resolt-order branch October 16, 2024 11:58
Copy link
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!

kt3k added a commit to kt3k/deno that referenced this pull request Oct 29, 2024
bartlomieju pushed a commit that referenced this pull request Oct 29, 2024
bartlomieju pushed a commit that referenced this pull request Oct 29, 2024
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