Skip to content

Conversation

@aduh95
Copy link
Contributor

@aduh95 aduh95 commented Jan 7, 2022

No description provided.

@aduh95 aduh95 added the semver-major PRs that contain breaking changes and should be released in the next major version. label Jan 7, 2022
@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/net

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run. labels Jan 7, 2022
@aduh95 aduh95 force-pushed the no-dns-lookup-options-type-coercion branch from 740a691 to 8e53d29 Compare April 3, 2022 17:08
@aduh95 aduh95 added the request-ci Add this label to start a Jenkins CI on a PR. label Apr 3, 2022
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Apr 3, 2022
@nodejs-github-bot
Copy link
Collaborator

@aduh95 aduh95 force-pushed the no-dns-lookup-options-type-coercion branch from 8e53d29 to 13c8788 Compare April 3, 2022 19:39
@nodejs-github-bot
Copy link
Collaborator

@aduh95
Copy link
Contributor Author

aduh95 commented Apr 3, 2022

@nodejs/tsc can we get this into v18.x?

Copy link
Member

@Trott Trott left a comment

Choose a reason for hiding this comment

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

LGTM if CITGM doesn't find problems.

uv_ip6_name(&interfaces[i].address.address6, ip, sizeof(ip));
uv_ip6_name(&interfaces[i].netmask.netmask6, netmask, sizeof(netmask));
family = env->ipv6_string();
family = Integer::New(env->isolate(), 6);
Copy link
Member

Choose a reason for hiding this comment

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

I'm concerned about these two specific changes, moving from IPv4 to 4 and IPv6 to 6. I'm 100% sure those will break some of my modules (Fastify v4).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The reason for this change is that currently passing an address object to the DNS resolver, the 'IPv6' string is converted to 0.
Would it be reasonable to ask you to update the code that using that to expect one form or the other? Something like info.family === 6 || info.family === 'IPv6'? If not, we could make the DNS resolver accept a string and interpret 'IPv6' same as 6.

Copy link

@Apollon77 Apollon77 Apr 25, 2022

Choose a reason for hiding this comment

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

I assume this change will hurt the community a lot.

I personally would see this:

If not, we could make the DNS resolver accept a string and interpret 'IPv6' same as 6.

as the better solution

Copy link
Contributor

Choose a reason for hiding this comment

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

Agreed here. I realize that Node v18 was a major version change, but changing the output of a widely used API (socket.address()) just so another core-Node API could match up with it instead of making the DNS resolver more flexible seems pretty overkill!

Copy link
Contributor

Choose a reason for hiding this comment

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

Now that it's out in the wild, can confirm it caused some widespread breaking for us that's going to make node 18 a pain and very uncertain to roll out.

Copy link

Choose a reason for hiding this comment

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

I assume this change will hurt the community a lot.

Can confirm completely unexpected breakage

Choose a reason for hiding this comment

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

@aduh95 @mcollina Any chance to think about that change again and consider alternatives?

Choose a reason for hiding this comment

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

maybe a new issue is more visible to the nodejs team and allows a better discussion ... so see #43014 ... Please "thumbs up" it if you support to adjust this to be backward compatible. Thank you

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

lgtm

@aduh95 aduh95 force-pushed the no-dns-lookup-options-type-coercion branch from 13c8788 to 84164de Compare April 4, 2022 13:31
@aduh95
Copy link
Contributor Author

aduh95 commented Apr 4, 2022

CITGM (master): https://ci.nodejs.org/view/Node.js-citgm/job/citgm-smoker/2904/
CITGM (aduh95:no-dns-lookup-options-type-coercion): https://ci.nodejs.org/view/Node.js-citgm/job/citgm-smoker/2905/

@mcollina mcollina added the notable-change PRs with changes that should be highlighted in changelogs. label Apr 4, 2022
@aduh95 aduh95 added request-ci Add this label to start a Jenkins CI on a PR. author ready PRs that have at least one approval, no pending requests for changes, and a CI started. labels Apr 6, 2022
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Apr 6, 2022
@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@richardlau
Copy link
Member

@aduh95 If it helps the failures in the recent CI runs for this PR have all been running inside containers.

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

IvanGoncharov added a commit to IvanGoncharov/apollo-server that referenced this pull request Apr 26, 2022
targos pushed a commit that referenced this pull request Apr 28, 2022
Refs: #41431
Fixes: #42787

PR-URL: #42789
Reviewed-By: Beth Griggs <bgriggs@redhat.com>
Reviewed-By: Mestery <mestery@protonmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Paolo Insogna <paolo@cowtech.it>
nodejs-github-bot pushed a commit that referenced this pull request Apr 28, 2022
Refs: #41431

PR-URL: #42795
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
glasser pushed a commit to IvanGoncharov/apollo-server that referenced this pull request Apr 28, 2022
trevor-scheer pushed a commit to apollographql/apollo-server that referenced this pull request Apr 28, 2022
frbuceta added a commit to loopbackio/loopback-next that referenced this pull request May 1, 2022
ref: #8530
See nodejs/node#41431
Signed-off-by: Francisco Buceta <frbuceta@gmail.com>
frbuceta added a commit to loopbackio/loopback-next that referenced this pull request May 1, 2022
ref: #8530
See nodejs/node#41431
Signed-off-by: Francisco Buceta <frbuceta@gmail.com>
frbuceta added a commit to loopbackio/loopback-next that referenced this pull request May 2, 2022
See nodejs/node#41431

Signed-off-by: Francisco Buceta <frbuceta@gmail.com>
targos pushed a commit that referenced this pull request May 2, 2022
Refs: #41431

PR-URL: #42795
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
frbuceta added a commit to loopbackio/loopback-next that referenced this pull request May 3, 2022
See nodejs/node#41431

Signed-off-by: Francisco Buceta <frbuceta@gmail.com>
nrako added a commit to nrako/deno that referenced this pull request Nov 30, 2025
Aligns Deno's `server.address()` with Node.js v18.4.0+ behavior by
returning the `family` property as a string ("IPv4" or "IPv6") rather
than a number.

Node.js briefly changed `family` from string to number in v18.0.0
(nodejs/node#41431), but reverted in v18.4.0 (nodejs/node#43054) due
to ecosystem breakage (nodejs/node#43014).

This fix ensures compatibility with npm packages that rely on the
string format, which has been the stable API since Node.js v18.4.0.

Refs:
- nodejs/node#43054
- nodejs/node@70b516e

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
nrako added a commit to nrako/deno that referenced this pull request Nov 30, 2025
Aligns Deno's `server.address()` with Node.js v18.4.0+ behavior by
returning the `family` property as a string ("IPv4" or "IPv6") rather
than a number.

Node.js briefly changed `family` from string to number in v18.0.0
(nodejs/node#41431), but reverted in v18.4.0 (nodejs/node#43054) due
to ecosystem breakage (nodejs/node#43014).

This fix ensures compatibility with npm packages that rely on the
string format, which has been the stable API since Node.js v18.4.0.

Refs:
- nodejs/node#43054
- nodejs/node@70b516e

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
nrako added a commit to nrako/deno that referenced this pull request Nov 30, 2025
Aligns Deno's `server.address()` with Node.js v18.4.0+ behavior by
returning the `family` property as a string ("IPv4" or "IPv6") rather
than a number.

Node.js briefly changed `family` from string to number in v18.0.0
(nodejs/node#41431), but reverted in v18.4.0 (nodejs/node#43054) due
to ecosystem breakage (nodejs/node#43014).

This fix ensures compatibility with npm packages that rely on the
string format, which has been the stable API since Node.js v18.4.0.

Refs:
- nodejs/node#43054
- nodejs/node@70b516e

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
nrako added a commit to nrako/deno that referenced this pull request Nov 30, 2025
Aligns Deno's `server.address()` with Node.js v18.4.0+ behavior by
returning the `family` property as a string ("IPv4" or "IPv6") rather
than a number.

Node.js briefly changed `family` from string to number in v18.0.0
(nodejs/node#41431), but reverted in v18.4.0 (nodejs/node#43054) due
to ecosystem breakage (nodejs/node#43014).

This fix ensures compatibility with npm packages that rely on the
string format, which has been the stable API since Node.js v18.4.0.

Refs:
- nodejs/node#43054
- nodejs/node@70b516e

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
nrako added a commit to nrako/deno that referenced this pull request Nov 30, 2025
Aligns Deno's `server.address()` with Node.js v18.4.0+ behavior by
returning the `family` property as a string ("IPv4" or "IPv6") rather
than a number.

Node.js briefly changed `family` from string to number in v18.0.0
(nodejs/node#41431), but reverted in v18.4.0 (nodejs/node#43054) due
to ecosystem breakage (nodejs/node#43014).

This fix ensures compatibility with npm packages that rely on the
string format, which has been the stable API since Node.js v18.4.0.

Refs:
- nodejs/node#43054
- nodejs/node@70b516e

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
nrako added a commit to nrako/deno that referenced this pull request Nov 30, 2025
Aligns Deno's Node.js compatibility layer with Node.js v18.4.0+ behavior
by returning the `family` property as a string ("IPv4" or "IPv6") rather
than a number in `server.address()` and socket address methods.

Node.js briefly changed `family` from string to number in v18.0.0
(nodejs/node#41431), but reverted in v18.4.0 (nodejs/node#43054) due to
ecosystem breakage (nodejs/node#43014).

Changes:
- `http.Server.address()`, `https.Server.address()`, `http2.Server.address()`
  now include `family` property as string
- `net.Server.address()` returns string `family` via tcp_wrap.ts
- `socket.remoteFamily` returns string instead of number
- `dns.lookup()` accepts both numeric (0, 4, 6) and string ("IPv4", "IPv6")
  family values, matching Node.js behavior

Family value derivation follows Node.js C++ implementation:
- isIP() === 4 → "IPv4"
- isIP() === 6 → "IPv6"
- isIP() === 0 → undefined (defensive, matches Node.js behavior for
  non-IP addresses, though not practically reachable via TCP server APIs)

Refs:
- nodejs/node#43054
- nodejs/node@70b516e

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
nrako added a commit to nrako/deno that referenced this pull request Dec 4, 2025
Aligns Deno's Node.js compatibility layer with Node.js v18.4.0+ behavior
by returning the `family` property as a string ("IPv4" or "IPv6") rather
than a number in `server.address()` and socket address methods.

Node.js briefly changed `family` from string to number in v18.0.0
(nodejs/node#41431), but reverted in v18.4.0 (nodejs/node#43054) due to
ecosystem breakage (nodejs/node#43014).

Changes:
- `http.Server.address()`, `https.Server.address()`, `http2.Server.address()`
  now include `family` property as string
- `net.Server.address()` returns string `family` via tcp_wrap.ts
- `socket.remoteFamily` returns string instead of number
- `dns.lookup()` accepts both numeric (0, 4, 6) and string ("IPv4", "IPv6")
  family values, matching Node.js behavior

Family value derivation follows Node.js C++ implementation:
- isIP() === 4 → "IPv4"
- isIP() === 6 → "IPv6"
- isIP() === 0 → undefined (defensive, matches Node.js behavior for
  non-IP addresses, though not practically reachable via TCP server APIs)

Refs:
- nodejs/node#43054
- nodejs/node@70b516e

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Tango992 added a commit to denoland/deno that referenced this pull request Dec 6, 2025
## Summary

Aligns Deno's Node.js compatibility layer (`node:net`, `node:http`,
`node:https`,
`node:http2`, `node:dns`) with Node.js v18.4.0+ behavior by returning
the `family`
property as a string (`"IPv4"` or `"IPv6"`) rather than a number in
`server.address()`
   and socket address methods.

Node.js briefly changed `family` from string to number in v18.0.0
(nodejs/node#41431),
   but reverted in v18.4.0 (nodejs/node#43054) due to ecosystem breakage
   (nodejs/node#43014).

This fix ensures compatibility with npm packages that rely on the string
format, which
   has been the stable API since Node.js v18.4.0.

   ## Changes

- Modified `ext/node/polyfills/http.ts` to add `family` property to
`address()` return
- Modified `ext/node/polyfills/internal_binding/tcp_wrap.ts` to return
string `family`
instead of number in `getsockname()`, `getpeername()`, and `#connect()`
- Modified `ext/node/polyfills/net.ts` to fix `socket.remoteFamily`
getter (no longer
   needs conversion since `family` is now a string)
   - Modified `ext/node/polyfills/dns.ts` and
`ext/node/polyfills/internal/dns/promises.ts` to accept string family
values (`"IPv4"`,
`"IPv6"`) in `lookup()`, matching [Node.js
behavior](https://nodejs.org/api/dns.html#dnslookuphostname-options-callback)
- Added tests in `tests/unit_node/http_test.ts`,
`tests/unit_node/http2_test.ts`,
   `tests/unit_node/https_test.ts`, `tests/unit_node/dns_test.ts`, and
   `tests/unit_node/net_test.ts`

   ## Node.js Compatibility Note

For non-IP addresses (when `isIP()` returns 0), the `family` property is
`undefined`.
This matches Node.js C++ behavior in
[`AddressToJS`](https://github.com/nodejs/node/blob/main/src/tcp_wrap.cc)
where family
is only set for `AF_INET` (`"IPv4"`) and `AF_INET6` (`"IPv6"`), and left
undefined
   otherwise.

   ## Refs

   - nodejs/node#43054
   - nodejs/node@70b516e


<!--
Before submitting a PR, please read
https://docs.deno.com/runtime/manual/references/contributing

1. Give the PR a descriptive title.

  Examples of good title:
    - fix(std/http): Fix race condition in server
    - docs(console): Update docstrings
    - feat(doc): Handle nested reexports

  Examples of bad title:
    - fix #7123
    - update docs
    - fix bugs

2. Ensure there is a related issue and it is referenced in the PR text.
3. Ensure there are tests that cover the changes.
4. Ensure `cargo test` passes.
5. Ensure `./tools/format.js` passes without changing files.
6. Ensure `./tools/lint.js` passes.
7. Open as a draft PR if your work is still in progress. The CI won't
run
   all steps, but you can add '[ci]' to a commit message to force it to.
8. If you would like to run the benchmarks on the CI, add the 'ci-bench'
label.
-->

---------

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Daniel Rahmanto <daniel.rahmanto@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c++ Issues and PRs that require attention from people who are familiar with C++. commit-queue-rebase Add this label to allow the Commit Queue to land a PR in several commits. lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run. notable-change PRs with changes that should be highlighted in changelogs. semver-major PRs that contain breaking changes and should be released in the next major version.

Projects

None yet

Development

Successfully merging this pull request may close these issues.