Repository navigation
Conversation
Error::get folded ARES_ENODATA and ARES_ENONAME into ENOTFOUND for every c-ares caller, and Error::code folded EBADNAME the same way. Node applies that fold only to getaddrinfo and getnameinfo, which back dns.lookup and dns.lookupService. A NODATA answer to resolve6() or reverse() now rejects with ENODATA and a malformed name with EBADNAME, like Node. The fold moves to Error::for_lookup, which init_eai and the ares_getaddrinfo and ares_getnameinfo callbacks apply.
|
Updated 8:57 PM PT - Oct 31st, 2026
✅ @robobun, your commit dd9aa5351eefe7eed804dcefbb0b1ff7077845a0 passed in 🧪 To try this PR locally: bunx bun-pr 47587That installs a local version of the PR into your bun-47587 --bun |
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
c-ares status mapping src/cares_sys/c_ares.rs |
Error::get preserves c-ares statuses. Lookup callbacks and getaddrinfo errors apply lookup-specific mapping. Error::code reports distinct codes for EBADNAME and ENONAME. |
Node DNS results src/js/node/dns.ts, test/js/node/dns/node-dns.test.js |
Empty results now produce ENOTFOUND. Tests cover NODATA, NXDOMAIN, malformed names, and lookup errors. |
Possibly related issues
- oven-sh/bun#44777 — The resolver status mapping changes address the ENODATA behavior. The cache-TTL issue described there is not addressed.
Suggested reviewers: dylan-conway
Severity of issue fixed: Medium
Merge Risk: 
Minimal · up to dd9aa
-
No actionable merge-blocking issue is established. The DNS changes appear mergeable subject to normal build and test checks, including the deferred DNS tests.
Pre-merge checks: 
4
-
Full details: Description check
-
Explanation
The description explains the problem, implementation, expected behavior, testing, compatibility effects, and known limitations. It does not use the exact template headings, but it provides the required information in equivalent sections.
Full details: Linked Issues check
-
Explanation
The PR meets both active linked coding objectives. For
#47578,Error::getpreservesARES_ENODATA, soresolve*reportsENODATAfor NODATA answers. For#37314, c-aresEBADNAMEremains distinct, sodns.resolve4reportsEBADNAMEfor malformed names. The tests cover these cases.Error::for_lookuppreservesENOTFOUNDfor lookup paths.
Full details: Out of Scope Changes check
-
Explanation
The changes stay within the linked DNS error-mapping scope. The lookup mapping,
throwIfEmptycorrection, and focused DNS tests support the requested behavior. No unrelated product change is shown in the reviewed changes.
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
There was a problem hiding this comment.
Beyond the inline findings, I also checked the remaining Error::get callers (hostent/reply/any thunks, ares_get_servers_ports/set_servers) — all are resolve*/reverse or channel-config paths where the raw c-ares status is the intended Node behavior — and confirmed no runtime code branches on the folded variants: every Error::ENOTFOUND reference in src/runtime constructs the error for null/invalid-hostname rejections rather than matching on it, and ws.ts's code === "ENOTFOUND" check is fed by the socket connect path, which still folds through init_eai.
Extended reasoning...
The change moves the ENODATA/ENONAME/EBADNAME-to-ENOTFOUND fold out of c_ares::Error::get into a new for_lookup applied only by the getaddrinfo/getnameinfo thunks and init_eai, fixes the code() string table, and rewrites throwIfEmpty in src/js/node/dns.ts; it touches no security-sensitive surface. The source change is small and consistent across the c-ares, libc and libuv backends, but the inline findings about the new tests (one depends on the host's real resolver, one assertion never reaches the fold it claims to cover) mean a human should still look before merging.
Findings marked 🟡 are optional suggestions and need no follow-up push.
…ver call The child test used a..b, which lookup rejects before any query, and a node:dns lookup that asks the machine's resolver. A non-ASCII label makes c-ares itself return EBADNAME. The resolve* tests run on Windows too.
There was a problem hiding this comment.
The follow-up commits address what I raised earlier (the child test no longer calls the host resolver, the ä.test lookup now passes is_valid_hostname and reaches ares_getaddrinfo, and the resolve* describe runs on Windows), and this pass found no new bugs. Because resolve*/reverse now surface ENODATA/EBADNAME where they used to report ENOTFOUND, a maintainer should still sign off on the user-visible code change.
What was reviewed:
- Every
Error::getcaller: the hostent/reply/any thunks (resolve*, reverse) stay unfolded; only the addrinfo and nameinfo thunks plusinit_eaifold, and allinit_eaicallers (dns.rs, FetchTasklet, socket_body, udp_socket) are lookup paths. init_eaion both platforms: the WindowsUV_EAI_NODATA/NONAMEarms were previously dead behind the early return and now feed.map(for_lookup); the POSIX SOCKTYPE/glibc early returns never produce a folded variant.- Existing suite assertions on
DNS_ENOTFOUND(test/js/bun/dns/resolve-dns.test.ts) are all lookup-path and keep passing; no test asserted the oldNo records found/ENODATAfromthrowIfEmpty.
Extended reasoning...
The change touches src/cares_sys/c_ares.rs (moves the ENODATA/ENONAME/EBADNAME to ENOTFOUND fold out of the shared Error::get into a new Error::for_lookup applied by the getaddrinfo/getnameinfo thunks and init_eai, and renames the DNS_ code strings for EBADNAME and ENONAME), src/js/node/dns.ts (throwIfEmpty reports ENOTFOUND/errno 4), and adds a hermetic local UDP DNS fixture with four tests in test/js/node/dns/node-dns.test.js. It touches no security-sensitive surface. The code addresses the prior inline findings and the sibling-site audit turned up nothing, but the change alters observable error codes of node:dns resolve*/reverse for existing callers and I could not build or run the Rust/test suite here, so a human maintainer should weigh the compat change.
|
Closing as stale: this PR conflicts with main, and its last commit is from 2026-10-31. The branch stays, so the work is not lost. To pick it up again, rebase the branch on main and reopen this PR. |
Fixes #47578, fixes #37314
Problem
dns.resolve6()(and every otherresolve*) rejects a NODATA answer (NOERROR with an empty answer section) withqueryAaaa ENOTFOUND host. Node rejects it withqueryAaaa ENODATA host(dns.NODATA). A malformed name (a..b) getsENOTFOUNDtoo, where Node reportsqueryA EBADNAME a..b. Libraries such as the AWS DAX client branch on these codes to tell "no AAAA record" from "no such name".c_ares::Error::get(src/cares_sys/c_ares.rs:1826). It foldsARES_ENODATAandARES_ENONAMEintoENOTFOUNDfor every c-ares callback.Error::codefoldsEBADNAMEthe same way. Node applies that fold only to the getaddrinfo and getnameinfo codes behinddns.lookupanddns.lookupService(lib/internal/errors.js,dnsException). Forresolve*,query*andreverseit reports the c-ares status as is (cares_wrap.cc,ToErrorCodeString).Fix
Error::getandError::codenow map the c-ares status 1:1. A NODATA answer isENODATAand a malformed name isEBADNAME, forresolve*andreverse, like Node.Error::for_lookup. The three lookup producers apply it:Error::init_eai(libc, system and libuv backends), theares_getaddrinfocallback (the c-ares backend, the default on Linux) and theares_getnameinfocallback (lookupService).dns.lookup,dns.lookupService,fetch()andBun.connectkeepENOTFOUNDon every backend.throwIfEmptyinsrc/js/node/dns.ts, the fallback for an emptylookupresult, reportsENOTFOUNDinstead of anENODATAthat Node'slookupnever emits.test/js/node/dns/node-dns.test.js(four new tests against a local UDP DNS server, stock bun fails two). Alsotest/js/node/dns/,test/js/bun/dns/,socket-dns-error.test.ts,dgram.test.ts,udp_socket.test.ts,websocket/error-event.test.tsand the nodetest-dns.js,test-c-ares.js,test-net-dns-error.js,test-http-dns-error.jsfiles.Background
ARES_*status.Error::getturns it into thec_ares::Errorenum, andsrc/runtime/dns_jsc/cares_jsc.rsbuilds theDNSExceptionfromError::code(without theDNS_prefix),errnoandlabel.dns.lookupanddns.lookupServicecall getaddrinfo(3) and getnameinfo(3) through libuv and mapEAI_NODATAandEAI_NONAMEtoENOTFOUND.resolve*andreversecall c-ares and report its status unchanged. Bun'slookupcan also useares_getaddrinfo, and itslookupServiceusesares_getnameinfo, so the fold has to apply there too.Error::getalone: the c-ares lookup backend would then reportENODATAandEBADNAMEfromdns.lookup, which Node never does. Moving the fold to the lookup entry points keeps one rule in one place. node:dns: report locally-rejected malformed names as EBADNAME, not ENOTFOUND #35591 fixes theEBADNAMEhalf with the fold in the lookup request handler. This PR covers that case with the same test input, so node:dns: report locally-rejected malformed names as EBADNAME, not ENOTFOUND #35591 can close.ENODATAis reported asENOTFOUND" as an unchanged difference. This PR fixes it on main. The new tests describe the expected codes for that rewrite too: the fold belongs to the lookup request kinds, not to every answer.Downsides
err.code === "ENOTFOUND"fromresolve*orreversefor a NODATA answer or a malformed name now seesENODATAorEBADNAME. That is the Node behaviour.dns.lookup,lookupService,fetch()andBun.connectare unchanged.matchon the enum. No allocation, no syscall.Notes
lookupServicethunk,throwIfEmpty, theerrnoandnamepins in the new tests, the link to node:dns: report locally-rejected malformed names as EBADNAME, not ENOTFOUND #35591 and Different error thrown when a BADNAME host is passed todns.resolve4#37314, the note on Replace c-ares with a DNS resolver in safe Rust #47076).lookupServicereportENODATAwith only theError::getchange. Theares_getnameinfocallback now folds too, and the child-process test checkslookupServiceon that answer.throwIfEmptyhas no known trigger: the native lookup paths reject a null result withENOTFOUNDbefore it runs.errnois a number in Bun andundefinedin Node for a c-ares error.resolve("")throwsERR_INVALID_ARG_TYPEin Bun and rejects withECONNREFUSEDin Node.test/js/node/dns/andtest/js/bun/dns/fail the same way on main in the sandbox used here (no internet).no test proof · iteration 0 · platform-specific test(s) that do not run on this machine, deferring to CI, which covers all platforms: test/js/node/dns/node-dns.test.js