deno/ext
Nicholas R bc9d356059
Some checks are pending
ci / test debug windows-x86_64 (push) Blocked by required conditions
ci / test release windows-x86_64 (push) Blocked by required conditions
ci / pre-build (push) Waiting to run
ci / test debug linux-aarch64 (push) Blocked by required conditions
ci / test release linux-aarch64 (push) Blocked by required conditions
ci / test debug macos-aarch64 (push) Blocked by required conditions
ci / test release macos-aarch64 (push) Blocked by required conditions
ci / bench release linux-x86_64 (push) Blocked by required conditions
ci / test debug linux-x86_64 (push) Blocked by required conditions
ci / test release linux-x86_64 (push) Blocked by required conditions
ci / test debug macos-x86_64 (push) Blocked by required conditions
ci / test release macos-x86_64 (push) Blocked by required conditions
ci / lint debug linux-x86_64 (push) Blocked by required conditions
ci / lint debug macos-x86_64 (push) Blocked by required conditions
ci / lint debug windows-x86_64 (push) Blocked by required conditions
ci / build libs (push) Blocked by required conditions
ci / publish canary (push) Blocked by required conditions
fix(node/net): return string family in server.address() (#31465)
## 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>
2025-12-06 10:51:55 +07:00
..
broadcast_channel refactor: merge deno_broadcast_channel into deno_web (#31198) 2025-11-06 08:36:16 +01:00
bundle 2.5.6 (#31136) 2025-10-29 23:50:18 +00:00
cache Revert "refactor: merge deno_cache into deno_web (#31183)" (#31205) 2025-11-06 09:25:55 +00:00
canvas feat(ext/web): add ImageData Float16Array support (#31394) 2025-11-27 13:04:43 +01:00
console refactor: merge deno_console into deno_web (#31185) 2025-11-05 08:46:48 +01:00
cron refactor: merge deno_console into deno_web (#31185) 2025-11-05 08:46:48 +01:00
crypto refactor: merge deno_console into deno_web (#31185) 2025-11-05 08:46:48 +01:00
fetch refactor: remove permission traits + generics from extension crates (#31284) 2025-11-17 10:30:36 -08:00
ffi refactor: remove permission traits + generics from extension crates (#31284) 2025-11-17 10:30:36 -08:00
fs refactor: remove permission traits + generics from extension crates (#31284) 2025-11-17 10:30:36 -08:00
http fix: clippy::derivable_impls (#31460) 2025-12-02 00:21:36 +01:00
io 2.5.6 (#31136) 2025-10-29 23:50:18 +00:00
kv refactor: remove permission traits + generics from extension crates (#31284) 2025-11-17 10:30:36 -08:00
napi refactor: remove permission traits + generics from extension crates (#31284) 2025-11-17 10:30:36 -08:00
net refactor: remove permission traits + generics from extension crates (#31284) 2025-11-17 10:30:36 -08:00
node fix(node/net): return string family in server.address() (#31465) 2025-12-06 10:51:55 +07:00
os feat: add --ignore-env=... (#31187) 2025-11-19 15:49:06 +00:00
process fix(node): support advanced serialization in IPC (#31380) 2025-11-26 23:15:32 +00:00
rt_helper 2.5.6 (#31136) 2025-10-29 23:50:18 +00:00
signals fix(ext/signals): don't run exit hooks at non-exit times (#31269) 2025-11-14 07:15:37 +09:00
telemetry fix: clippy::derivable_impls (#31460) 2025-12-02 00:21:36 +01:00
tls 2.5.6 (#31136) 2025-10-29 23:50:18 +00:00
url refactor: merge deno_url into deno_web (#31182) 2025-11-04 10:33:51 +01:00
web Revert "feat: use Node.js timers by default (#31272)" (#31490) 2025-12-04 00:50:11 +00:00
webgpu feat(cli): filter out common internal frames that add noise, dim and grey internal frames in stack traces (#31247) 2025-11-12 07:40:40 -08:00
webidl 2.5.6 (#31136) 2025-10-29 23:50:18 +00:00
websocket refactor: remove permission traits + generics from extension crates (#31284) 2025-11-17 10:30:36 -08:00
webstorage 2.5.6 (#31136) 2025-10-29 23:50:18 +00:00