Real DNS resolution for getaddrinfo under -sNODERAWSOCKETS - #27693
Merged
Merged
Conversation
sbc100
reviewed
Sep 14, 2026
guybedford
force-pushed
the
noderawsockets-dns
branch
2 times, most recently
from
September 16, 2026 05:57
6df784b to
475c8fc
Compare
sbc100
reviewed
Sep 16, 2026
sbc100
reviewed
Sep 16, 2026
guybedford
force-pushed
the
noderawsockets-dns
branch
from
September 16, 2026 19:02
475c8fc to
e00a7e5
Compare
guybedford
force-pushed
the
noderawsockets-dns
branch
from
September 16, 2026 20:04
c55048c to
c8c57a3
Compare
sbc100
reviewed
Sep 16, 2026
guybedford
force-pushed
the
noderawsockets-dns
branch
from
September 16, 2026 20:26
66235dc to
fa45fa6
Compare
sbc100
reviewed
Sep 16, 2026
sbc100
approved these changes
Sep 16, 2026
/etc/hosts entries (read through the emscripten FS) resolve synchronously, other hostnames resolve via node:dns, blocking where the calling stack can wait (a proxied pthread via PROXY_SYNC_ASYNC, ASYNCIFY/JSPI by suspending) and returning EAI_AGAIN otherwise. Results may be a linked list, which freeaddrinfo now frees in full.
…leAsync, support ASYNCIFY
guybedford
force-pushed
the
noderawsockets-dns
branch
from
September 16, 2026 22:09
e3f0723 to
f5b1482
Compare
guybedford
enabled auto-merge (squash)
September 16, 2026 22:11
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This gives
getaddrinfo()real name resolution under-sNODERAWSOCKETS. Split out from #27182, which also added a new asynchronous DNS API; this PR is only the change to the existing blocking API, allowing any async API work to follow separately.Previously every hostname resolved to a fake
172.29.x.xaddress, which is fine for the websocket proxy transport but not for real Node.js sockets, where the address has to be connectable.node:dns(which honors the host's/etc/hosts). The lookup is asynchronous, sogetaddrinfoblocks by returning a Promise where the calling stack can wait on it: a sync-proxied pthread (PROXY_SYNC_ASYNC, e.g.main()underPROXY_TO_PTHREAD), orASYNCIFY/JSPIby suspending throughAsyncify.handleAsync, which also holds a runtime keepalive so a user callback completing mid-lookup does not exit the runtime. Numeric addresses and errors still return synchronously, soJSPIdoes not pay a microtask on those.EAI_AGAINwithout starting a lookup.addrinfolinked list (multiple DNS records,AF_UNSPEC), andfreeaddrinfowalks the whole chain.Everything is gated on
NODERAWSOCKETS; without itgetaddrinfois unchanged.Implementation-wise
getaddrinfokeeps its existing body and returns either anEAI_*code or a Promise of one. The pthread proxy receive side now accepts a synchronous value from aPROXY_SYNC_ASYNCfunction (Promise.resolve(rtn).then(...)), so no wrapper is needed for the sync paths.Tested with
test_noderawsockets_dns(numeric,EAI_AGAINsingle-threaded), andtest_noderawsockets_dns_blocking{,_asyncify,_jspi}(multi-address lists across families, and a timer firing during the lookup underEXIT_RUNTIME).Made with AI assistance under my review