Skip to content

fix(ext/node): throw ERR_INVALID_ARG_VALUE for falsy dns.lookup hostname - #34234

Merged
littledivy merged 1 commit into
mainfrom
orch/divybot-139
May 19, 2026
Merged

littledivy merged 1 commit into
mainfrom
orch/divybot-139

Conversation

@divybot

@divybot divybot commented May 19, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • dns.lookup and dnsPromises.lookup now throw/reject ERR_INVALID_ARG_VALUE synchronously when called with a falsy hostname, matching Node 25+ (node/lib/dns.js, node/lib/internal/dns/promises.js). Previously Deno emitted a one-shot DEP0118 DeprecationWarning and resolved with a null address — Node removed that legacy fallback.
  • Drops the now-unused emitInvalidHostnameWarning helper from internal/dns/utils.ts.
  • Enables the previously skipped node_compat parallel tests test-dns-lookup.js and test-dns-lookup-promises.js. Those tests stub cares.getaddrinfo and assert on dns.lookup(false, options, cb) / dnsPromises.lookup(false, options), expecting a sync throw/reject. Before this fix they bailed out with an unexpected DeprecationWarning ("DEP0118"), which the issue described as "spurious punycode DEP0040" — the actual emitted code is DEP0118 (invalid hostname), not DEP0040.

Test plan

  • cargo test --test node_compat -- test-dns-lookup — passes locally (parallel test-dns-lookup.js, test-dns-lookup-promises.js, test-dns-lookup-promises-options-deprecated.js, test-dns-lookupService.js, test-dns-lookupService-promises.js, internet test-dns-lookup.js).
  • Verified dnsPromises.lookup('127.0.0.1', { all: true }) still resolves correctly (untouched code path for IP hostnames).

Closes denoland/orchid#139

Match Node 25+ behavior: when `dns.lookup` (or `dnsPromises.lookup`) is
called with a falsy hostname, throw/reject `ERR_INVALID_ARG_VALUE`
synchronously instead of emitting a DEP0118 DeprecationWarning and
resolving with a null address. Node removed the legacy fallback path.

Enables the previously commented-out node_compat parallel tests
`test-dns-lookup.js` and `test-dns-lookup-promises.js`, which exercise
this code path via `assert.throws`/`assert.rejects` on a falsy hostname
and would fail loudly when the unexpected DEP0118 fired.

Closes denoland/orchid#139

Co-Authored-By: Divy Srivastava <me@littledivy.com>
@divybot divybot changed the title node compat: enable dns.lookup tests by matching Node warning/error behavior fix(ext/node): throw ERR_INVALID_ARG_VALUE for falsy dns.lookup hostname May 19, 2026
@littledivy
littledivy merged commit c990d56 into main May 19, 2026
136 of 138 checks passed
@littledivy
littledivy deleted the orch/divybot-139 branch May 19, 2026 14:52
littledivy added a commit to crowlKats/deno that referenced this pull request Jun 10, 2026
…ame (denoland#34234)

## Summary

- `dns.lookup` and `dnsPromises.lookup` now throw/reject
`ERR_INVALID_ARG_VALUE` synchronously when called with a falsy hostname,
matching Node 25+ (`node/lib/dns.js`,
`node/lib/internal/dns/promises.js`). Previously Deno emitted a one-shot
DEP0118 `DeprecationWarning` and resolved with a `null` address — Node
removed that legacy fallback.
- Drops the now-unused `emitInvalidHostnameWarning` helper from
`internal/dns/utils.ts`.
- Enables the previously skipped node_compat parallel tests
`test-dns-lookup.js` and `test-dns-lookup-promises.js`. Those tests stub
`cares.getaddrinfo` and assert on `dns.lookup(false, options, cb)` /
`dnsPromises.lookup(false, options)`, expecting a sync throw/reject.
Before this fix they bailed out with an unexpected `DeprecationWarning`
("DEP0118"), which the issue described as "spurious punycode DEP0040" —
the actual emitted code is DEP0118 (invalid hostname), not DEP0040.

## Test plan

- [x] `cargo test --test node_compat -- test-dns-lookup` — passes
locally (parallel `test-dns-lookup.js`, `test-dns-lookup-promises.js`,
`test-dns-lookup-promises-options-deprecated.js`,
`test-dns-lookupService.js`, `test-dns-lookupService-promises.js`,
internet `test-dns-lookup.js`).
- [x] Verified `dnsPromises.lookup('127.0.0.1', { all: true })` still
resolves correctly (untouched code path for IP hostnames).

Closes denoland/orchid#139

Co-authored-by: divybot <divybot@users.noreply.github.com>
Co-authored-by: Divy Srivastava <me@littledivy.com>
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.

2 participants