GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — dns: coalesce identical concurrent lookup() requests by orgads · Pull Request #62599 · nodejs/node

Conversation

@orgads

@orgads orgads commented Apr 5, 2026

Copy link
Copy Markdown
Contributor

When multiple callers issue dns.lookup() for the same (hostname, family, hints, order) concurrently, only one getaddrinfo call is now dispatched to the libuv threadpool. All callers share the result.

getaddrinfo is a blocking call that runs on the libuv threadpool (capped at 4 threads by default, with a slow I/O concurrency limit of 2). When DNS resolution is slow - e.g. ~10-20 s per call due to a misbehaving resolver - identical requests queue behind each other, causing timeouts that grow linearly with the number of concurrent callers:

Before: 100 parallel lookup('host') -> 50 batches × 10 s = 500+ s
After: 100 parallel lookup('host') -> 1 getaddrinfo call = ~10 s

This is particularly severe on WSL, where the DNS relay rewrites QNAMEs in responses (appending the search domain), causing glibc to discard them as non-matching and wait for a 5s timeout per retry.

The coalescing is keyed on (hostname, family, hints, order) so lookups with different options still get separate getaddrinfo calls. Each caller independently post-processes the shared raw result (applying the 'all' flag, constructing address objects, etc.).

Fixes: #62503

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@nodejs-github-bot

nodejs-github-bot commented Apr 5, 2026

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/net
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@nodejs-github-bot nodejs-github-bot added dns Issues and PRs related to the dns subsystem. needs-ci PRs that need a full CI run. labels Apr 5, 2026
@orgads
orgads force-pushed the dns-coalesce-lookup branch from 36f0f63 to c754d12 Compare April 5, 2026 10:56
@orgads
orgads force-pushed the dns-coalesce-lookup branch from c754d12 to b213b0f Compare April 5, 2026 11:09
@codecov

codecov Bot commented Apr 5, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.65%. Comparing base (3983092) to head (6e7026d).
⚠️ Report is 147 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #62599      +/-   ##
==========================================
- Coverage   92.96%   90.65%   -2.31%     
==========================================
  Files         428      797     +369     
  Lines      195232   278281   +83049     
  Branches    30184    53510   +23326     
==========================================
+ Hits       181492   252271   +70779     
- Misses      13413    16384    +2971     
- Partials      327     9626    +9299     
Files with missing lines Coverage Δ
lib/dns.js 99.48% <100.00%> (+0.82%) ⬆️
lib/internal/dns/promises.js 98.80% <100.00%> (+1.45%) ⬆️

... and 500 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

mcollina
mcollina requested changes Apr 5, 2026
View reviewed changes

@mcollina mcollina left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I think this might break async_hooks continuation, could you verify? Adding an AsyncResource on coalescing would be enough.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@orgads
orgads force-pushed the dns-coalesce-lookup branch from b213b0f to cee78bf Compare April 5, 2026 15:43
@orgads

orgads commented Apr 5, 2026

Copy link
Copy Markdown
Contributor Author

Great observation! Should be fixed now.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@orgads
orgads force-pushed the dns-coalesce-lookup branch from cee78bf to 610a0c3 Compare April 5, 2026 16:25
@mcollina mcollina added semver-minor PRs that contain new features and should be released in the next minor version. needs-citgm PRs that need a CITGM CI run. dont-land-on-v22.x PRs that should not land on the v22.x-staging branch and should not be released in v22.x. dont-land-on-v24.x PRs that should not land on the v24.x-staging branch and should not be released in v24.x. baking-for-lts PRs whose changes need more time before an LTS backport. and removed dont-land-on-v22.x PRs that should not land on the v22.x-staging branch and should not be released in v22.x. dont-land-on-v24.x PRs that should not land on the v24.x-staging branch and should not be released in v24.x. labels Apr 5, 2026
@mcollina

mcollina commented Apr 5, 2026

Copy link
Copy Markdown
Member

I have a feeling that the failing test on GHA is relevant, can you take a look?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@orgads

orgads commented Apr 6, 2026

Copy link
Copy Markdown
Contributor Author

I have a feeling that the failing test on GHA is relevant, can you take a look?

It doesn't look related. Similar failures happened here and here. Also, this test calls dns.resolve (c-ares query request), which wasn't touched in this change. Only dns.lookup (getaddrinfo) was touched.

The test is flaky, since it relies on external systems which may refuse or time out.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

ronag
ronag approved these changes Apr 7, 2026
View reviewed changes
Comment thread lib/dns.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

orgads added a commit to orgads/node that referenced this pull request Apr 22, 2026
@orgads
dns: coalesce identical concurrent lookup() requests
6572e6e
When multiple callers issue dns.lookup() for the same (hostname, family,
hints, order) concurrently, only one getaddrinfo call is now dispatched
to the libuv threadpool.  All callers share the result.

getaddrinfo is a blocking call that runs on the libuv threadpool (capped
at 4 threads by default, with a slow I/O concurrency limit of 2).  When
DNS resolution is slow - e.g. ~10-20 s per call due to a misbehaving
resolver - identical requests queue behind each other, causing timeouts
that grow linearly with the number of concurrent callers:

  Before: 100 parallel lookup('host') -> 50 batches × 10 s = 500+ s
  After:  100 parallel lookup('host') -> 1 getaddrinfo  call = ~10 s

This is particularly severe on WSL, where the DNS relay rewrites QNAMEs
in responses (appending the search domain), causing glibc to discard
them as non-matching and wait for a 5s timeout per retry.

The coalescing is keyed on (hostname, family, hints, order) so lookups
with different options still get separate getaddrinfo calls.  Each
caller independently post-processes the shared raw result (applying the
'all' flag, constructing address objects, etc.).

Signed-off-by: Orgad Shaneh <[email protected]>
PR-URL: nodejs#62599
Fixes: nodejs#62503
@orgads
orgads force-pushed the dns-coalesce-lookup branch from 610a0c3 to 6572e6e Compare April 22, 2026 04:30
@orgads

orgads commented Apr 22, 2026

Copy link
Copy Markdown
Contributor Author

Rebased.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@orgads

orgads commented May 19, 2026

Copy link
Copy Markdown
Contributor Author

ping?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@orgads
orgads requested a review from mcollina August 1, 2026 18:46
orgads added a commit to orgads/node that referenced this pull request Aug 1, 2026
@orgads
dns: coalesce identical concurrent lookup() requests
7ea9614
When multiple callers issue dns.lookup() for the same (hostname, family,
hints, order) concurrently, only one getaddrinfo call is now dispatched
to the libuv threadpool.  All callers share the result.

getaddrinfo is a blocking call that runs on the libuv threadpool (capped
at 4 threads by default, with a slow I/O concurrency limit of 2).  When
DNS resolution is slow - e.g. ~10-20 s per call due to a misbehaving
resolver - identical requests queue behind each other, causing timeouts
that grow linearly with the number of concurrent callers:

  Before: 100 parallel lookup('host') -> 50 batches × 10 s = 500+ s
  After:  100 parallel lookup('host') -> 1 getaddrinfo  call = ~10 s

This is particularly severe on WSL, where the DNS relay rewrites QNAMEs
in responses (appending the search domain), causing glibc to discard
them as non-matching and wait for a 5s timeout per retry.

The coalescing is keyed on (hostname, family, hints, order) so lookups
with different options still get separate getaddrinfo calls.  Each
caller independently post-processes the shared raw result (applying the
'all' flag, constructing address objects, etc.).

Signed-off-by: Orgad Shaneh <[email protected]>
PR-URL: nodejs#62599
Fixes: nodejs#62503
@orgads

orgads commented Aug 26, 2026

Copy link
Copy Markdown
Contributor Author

ping?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@panva panva added the author ready PRs with CI started, the required approvals, and no outstanding review comments. label Oct 23, 2026
@nodejs-github-bot

nodejs-github-bot commented Oct 23, 2026

Copy link
Copy Markdown
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/78588/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@orgads
dns: coalesce identical concurrent lookup() requests
6e7026d
When multiple callers issue dns.lookup() for the same (hostname, family,
hints, order) concurrently, only one getaddrinfo call is now dispatched
to the libuv threadpool.  All callers share the result.

getaddrinfo is a blocking call that runs on the libuv threadpool (capped
at 4 threads by default, with a slow I/O concurrency limit of 2).  When
DNS resolution is slow - e.g. ~10-20 s per call due to a misbehaving
resolver - identical requests queue behind each other, causing timeouts
that grow linearly with the number of concurrent callers:

  Before: 100 parallel lookup('host') -> 50 batches × 10 s = 500+ s
  After:  100 parallel lookup('host') -> 1 getaddrinfo  call = ~10 s

This is particularly severe on WSL, where the DNS relay rewrites QNAMEs
in responses (appending the search domain), causing glibc to discard
them as non-matching and wait for a 5s timeout per retry.

The coalescing is keyed on (hostname, family, hints, order) so lookups
with different options still get separate getaddrinfo calls.  Each
caller independently post-processes the shared raw result (applying the
'all' flag, constructing address objects, etc.).

Signed-off-by: Orgad Shaneh <[email protected]>
PR-URL: nodejs#62599
Fixes: nodejs#62503
@orgads
orgads force-pushed the dns-coalesce-lookup branch from 7ea9614 to 6e7026d Compare October 26, 2026 07:49
@orgads

orgads commented Oct 26, 2026

Copy link
Copy Markdown
Contributor Author

Rebased

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@orgads

orgads commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

@panva @mcollina ?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

panva
panva approved these changes Nov 5, 2026
View reviewed changes
@panva panva added the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Nov 5, 2026
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Nov 5, 2026
@nodejs-github-bot

nodejs-github-bot commented Nov 5, 2026

Copy link
Copy Markdown
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/78860/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@panva panva added the resume-ci Add this label to resume the latest eligible Jenkins CI run on a PR with an approving review. label Nov 5, 2026
@github-actions github-actions Bot removed the resume-ci Add this label to resume the latest eligible Jenkins CI run on a PR with an approving review. label Nov 5, 2026
@nodejs-github-bot

nodejs-github-bot commented Nov 5, 2026

Copy link
Copy Markdown
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/78865/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mcollina mcollina added the commit-queue PRs queued for automated landing through the Commit Queue. label Nov 5, 2026
@nodejs-github-bot nodejs-github-bot added commit-queue-failed PRs whose Commit Queue landing failed and need manual intervention before retrying. and removed commit-queue PRs queued for automated landing through the Commit Queue. labels Nov 5, 2026
@trivikr trivikr added commit-queue PRs queued for automated landing through the Commit Queue. and removed commit-queue-failed PRs whose Commit Queue landing failed and need manual intervention before retrying. labels Nov 6, 2026
@nodejs-github-bot
nodejs-github-bot merged commit ec4d4c2 into nodejs:main Nov 6, 2026
78 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@nodejs-github-bot

nodejs-github-bot commented Nov 6, 2026

Copy link
Copy Markdown
Collaborator

Landed in ec4d4c2

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@nodejs-github-bot nodejs-github-bot removed the commit-queue PRs queued for automated landing through the Commit Queue. label Nov 6, 2026
@orgads
orgads deleted the dns-coalesce-lookup branch November 6, 2026 03:35
aduh95 pushed a commit that referenced this pull request Nov 11, 2026
@orgads @aduh95
dns: coalesce identical concurrent lookup() requests
2360d38
When multiple callers issue dns.lookup() for the same (hostname, family,
hints, order) concurrently, only one getaddrinfo call is now dispatched
to the libuv threadpool.  All callers share the result.

getaddrinfo is a blocking call that runs on the libuv threadpool (capped
at 4 threads by default, with a slow I/O concurrency limit of 2).  When
DNS resolution is slow - e.g. ~10-20 s per call due to a misbehaving
resolver - identical requests queue behind each other, causing timeouts
that grow linearly with the number of concurrent callers:

  Before: 100 parallel lookup('host') -> 50 batches × 10 s = 500+ s
  After:  100 parallel lookup('host') -> 1 getaddrinfo  call = ~10 s

This is particularly severe on WSL, where the DNS relay rewrites QNAMEs
in responses (appending the search domain), causing glibc to discard
them as non-matching and wait for a 5s timeout per retry.

The coalescing is keyed on (hostname, family, hints, order) so lookups
with different options still get separate getaddrinfo calls.  Each
caller independently post-processes the shared raw result (applying the
'all' flag, constructing address objects, etc.).

Signed-off-by: Orgad Shaneh <[email protected]>
Fixes: #62503
PR-URL: #62599
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Robert Nagy <[email protected]>
Reviewed-By: Filip Skokan <[email protected]>
@github-actions github-actions Bot mentioned this pull request Nov 11, 2026
2026-11-12, Version 27.0.0-alpha.0.1.0 (Alpha) #67415
Merged
nodejs-github-bot added a commit that referenced this pull request Nov 11, 2026
@nodejs-github-bot
2026-11-12, Version 27.0.0-alpha.0.1.0 (Alpha)
dd138af
Notable changes:

child_process:
  * (SEMVER-MINOR) add subprocess.timedOut (Marco) #66639
crypto:
  * (SEMVER-MINOR) make X.509 inspection guards explicit (Filip Skokan) #67245
  * (SEMVER-MINOR) add X.509 generation with CSR support (Filip Skokan) #67245
dns:
  * (SEMVER-MINOR) coalesce identical concurrent lookup() requests (Orgad Shaneh) #62599
doc:
  * add efekrskl to collaborators (Efe Karasakal) #67376
  * add Philipp Dunkel to contributors (Philipp Dunkel) #67378
  * add christianaurichzm to collaborators (Christian Aurich Zanettini Martins) #67377
http:
  * (SEMVER-MINOR) batch body spans per parser execute (Guilherme Araújo) #67187
sea:
  * (SEMVER-MINOR) generate a compile cache for the VFS modules (Matteo Collina) #66768
worker:
  * (SEMVER-MINOR) preload streams into startup snapshot (Matteo Collina) #66311

PR-URL: #67415
aduh95 pushed a commit that referenced this pull request Nov 12, 2026
@nodejs-github-bot @aduh95
2026-11-12, Version 27.0.0-alpha.0.1.0 (Alpha)
4f23168
Notable changes:

child_process:
  * (SEMVER-MINOR) add subprocess.timedOut (Marco) #66639
crypto:
  * (SEMVER-MINOR) make X.509 inspection guards explicit (Filip Skokan) #67245
  * (SEMVER-MINOR) add X.509 generation with CSR support (Filip Skokan) #67245
dns:
  * (SEMVER-MINOR) coalesce identical concurrent lookup() requests (Orgad Shaneh) #62599
doc:
  * add efekrskl to collaborators (Efe Karasakal) #67376
  * add Philipp Dunkel to contributors (Philipp Dunkel) #67378
  * add christianaurichzm to collaborators (Christian Aurich Zanettini Martins) #67377
http:
  * (SEMVER-MINOR) batch body spans per parser execute (Guilherme Araújo) #67187
sea:
  * (SEMVER-MINOR) generate a compile cache for the VFS modules (Matteo Collina) #66768
worker:
  * (SEMVER-MINOR) preload streams into startup snapshot (Matteo Collina) #66311

PR-URL: #67415
@adelost

adelost commented Nov 26, 2026

Copy link
Copy Markdown

Nice fix! We ran into exactly this on Node 22. DNS went down and the
service kept growing until it ran out of memory. Tested this change
locally and memory stayed flat.

Any chance this gets backported to v26.x? Or even v22.x?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

gabylb pushed a commit to gabylb/node that referenced this pull request Nov 27, 2026
@orgads @gabylb
dns: coalesce identical concurrent lookup() requests
751ba98
When multiple callers issue dns.lookup() for the same (hostname, family,
hints, order) concurrently, only one getaddrinfo call is now dispatched
to the libuv threadpool.  All callers share the result.

getaddrinfo is a blocking call that runs on the libuv threadpool (capped
at 4 threads by default, with a slow I/O concurrency limit of 2).  When
DNS resolution is slow - e.g. ~10-20 s per call due to a misbehaving
resolver - identical requests queue behind each other, causing timeouts
that grow linearly with the number of concurrent callers:

  Before: 100 parallel lookup('host') -> 50 batches × 10 s = 500+ s
  After:  100 parallel lookup('host') -> 1 getaddrinfo  call = ~10 s

This is particularly severe on WSL, where the DNS relay rewrites QNAMEs
in responses (appending the search domain), causing glibc to discard
them as non-matching and wait for a 5s timeout per retry.

The coalescing is keyed on (hostname, family, hints, order) so lookups
with different options still get separate getaddrinfo calls.  Each
caller independently post-processes the shared raw result (applying the
'all' flag, constructing address objects, etc.).

Signed-off-by: Orgad Shaneh <[email protected]>
Fixes: nodejs#62503
PR-URL: nodejs#62599
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Robert Nagy <[email protected]>
Reviewed-By: Filip Skokan <[email protected]>
gabylb pushed a commit to gabylb/node that referenced this pull request Nov 27, 2026
@nodejs-github-bot @gabylb
2026-11-12, Version 27.0.0-alpha.0.1.0 (Alpha)
d26c0f2
Notable changes:

child_process:
  * (SEMVER-MINOR) add subprocess.timedOut (Marco) nodejs#66639
crypto:
  * (SEMVER-MINOR) make X.509 inspection guards explicit (Filip Skokan) nodejs#67245
  * (SEMVER-MINOR) add X.509 generation with CSR support (Filip Skokan) nodejs#67245
dns:
  * (SEMVER-MINOR) coalesce identical concurrent lookup() requests (Orgad Shaneh) nodejs#62599
doc:
  * add efekrskl to collaborators (Efe Karasakal) nodejs#67376
  * add Philipp Dunkel to contributors (Philipp Dunkel) nodejs#67378
  * add christianaurichzm to collaborators (Christian Aurich Zanettini Martins) nodejs#67377
http:
  * (SEMVER-MINOR) batch body spans per parser execute (Guilherme Araújo) nodejs#67187
sea:
  * (SEMVER-MINOR) generate a compile cache for the VFS modules (Matteo Collina) nodejs#66768
worker:
  * (SEMVER-MINOR) preload streams into startup snapshot (Matteo Collina) nodejs#66311

PR-URL: nodejs#67415
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@mcollina mcollina mcollina approved these changes
@panva panva panva approved these changes
@ronag ronag ronag approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

author ready PRs with CI started, the required approvals, and no outstanding review comments. baking-for-lts PRs whose changes need more time before an LTS backport. dns Issues and PRs related to the dns subsystem. needs-ci PRs that need a full CI run. needs-citgm PRs that need a CITGM CI run. semver-minor PRs that contain new features and should be released in the next minor version.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

dns.lookup: pending promises grow unboundedly under sustained EAI_AGAIN load

Uh oh!

There was an error while loading. Please reload this page.

7 participants

@orgads @nodejs-github-bot @mcollina @trivikr @adelost @panva @ronag
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.