Title: dns.lookup: pending promises grow unboundedly under sustained EAI_AGAIN load · Issue #62503 · nodejs/node · GitHub
Open Graph Title: dns.lookup: pending promises grow unboundedly under sustained EAI_AGAIN load · Issue #62503 · nodejs/node
X Title: dns.lookup: pending promises grow unboundedly under sustained EAI_AGAIN load · Issue #62503 · nodejs/node
Description: Version v24.14.1 Platform Linux 6.6.87.2-microsoft-standard-WSL2 x86_64 (Debian forky/sid) Subsystem dns What steps will reproduce the bug? When dns.promises.lookup() is called repeatedly for a hostname that triggers EAI_AGAIN (e.g. a no...
Open Graph Description: Version v24.14.1 Platform Linux 6.6.87.2-microsoft-standard-WSL2 x86_64 (Debian forky/sid) Subsystem dns What steps will reproduce the bug? When dns.promises.lookup() is called repeatedly for a hos...
X Description: Version v24.14.1 Platform Linux 6.6.87.2-microsoft-standard-WSL2 x86_64 (Debian forky/sid) Subsystem dns What steps will reproduce the bug? When dns.promises.lookup() is called repeatedly for a hos...
Opengraph URL: https://github.com/nodejs/node/issues/62503
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"dns.lookup: pending promises grow unboundedly under sustained EAI_AGAIN load","articleBody":"### Version\n\nv24.14.1\n\n### Platform\n\n```text\nLinux 6.6.87.2-microsoft-standard-WSL2 x86_64 (Debian forky/sid)\n```\n\n### Subsystem\n\ndns\n\n### What steps will reproduce the bug?\n\nWhen `dns.promises.lookup()` is called repeatedly for a hostname that triggers `EAI_AGAIN` (e.g. a nonsense TLD like `'asd'`), `getaddrinfo` blocks its libuv thread for ~10 seconds before rejecting. Under sustained load, new lookups queue behind the blocked threads and the number of unresolved promises grows without bound.\n\nIn our production system this manifests as a memory leak: each pending promise holds references to the calling closure (in our case, per-conversation config objects), and none of them can be GC'd until `getaddrinfo` eventually returns.\n\n**Minimal reproduction** — save as `repro.mjs`:\n\n```js\nimport { lookup } from 'node:dns/promises';\n\nconst HOSTNAME = 'asd'; // triggers EAI_AGAIN\nconst INTERVAL_MS = 2000;\nconst TOTAL = 50;\n\nlet pending = 0;\nlet started = 0;\nlet settled = 0;\n\nfunction fire() {\n const id = ++started;\n ++pending;\n const t0 = Date.now();\n console.log(`[#${id}] started (pending: ${pending})`);\n\n lookup(HOSTNAME).then(\n (result) => {\n --pending;\n ++settled;\n console.log(`[#${id}] resolved ${result.address} after ${Date.now() - t0}ms (pending: ${pending})`);\n },\n (err) => {\n --pending;\n ++settled;\n console.log(`[#${id}] rejected ${err.code} after ${Date.now() - t0}ms (pending: ${pending})`);\n }\n );\n}\n\nconst interval = setInterval(() => {\n if (started >= TOTAL) {\n clearInterval(interval);\n return;\n }\n fire();\n}, INTERVAL_MS);\n\nsetInterval(() => {\n console.log(`\\n--- status: started=${started} settled=${settled} pending=${pending} ---\\n`);\n}, 5000).unref();\n\nsetTimeout(() => {\n console.log(`\\n=== FINAL: started=${started} settled=${settled} stuck=${pending} ===`);\n if (pending > 0)\n console.log(`LEAK CONFIRMED: ${pending} lookup(s) never settled.`);\n else\n console.log('No leak detected.');\n process.exit(pending > 0 ? 1 : 0);\n}, TOTAL * INTERVAL_MS + 60_000);\n```\n\nRun:\n\n```\nnode repro.mjs\n```\n\n\n### How often does it reproduce? Is there a required condition?\n\nAlways\n\n### What is the expected behavior? Why is that the expected behavior?\n\nEach `lookup()` call should resolve or reject in bounded time, regardless of the hostname. Under sustained load, the number of pending (unresolved) promises should stay bounded — ideally proportional to the libuv thread pool size (`UV_THREADPOOL_SIZE`, default 4), not to the total number of requests issued.\n\n\n### What do you see instead?\n\n- Each `getaddrinfo` call for `'asd'` blocks a libuv thread for ~10 seconds before rejecting with `EAI_AGAIN`.\n- Only ~2 rejections return per 10-second cycle (thread pool saturation).\n- New lookups queue behind the blocked threads, so the pending count grows monotonically: 5 → 8 → 11 → 14 → 17 → 20 → …\n- Promises are never settled until their turn comes, which under continuous load may be never.\n\nSample output (trimmed):\n\n```\n[#1] started (pending: 1)\n[#2] started (pending: 2)\n[#3] started (pending: 3)\n[#4] started (pending: 4)\n[#5] started (pending: 5)\n[#6] started (pending: 6)\n[#1] rejected EAI_AGAIN after 10031ms (pending: 5)\n[#7] started (pending: 6)\n[#2] rejected EAI_AGAIN after 10014ms (pending: 5)\n\n--- status: started=7 settled=2 pending=5 ---\n\n[#8] started (pending: 6)\n...\n[#12] started (pending: 9)\n[#4] rejected EAI_AGAIN after 16024ms (pending: 8)\n\n--- status: started=12 settled=4 pending=8 ---\n\n...\n[#32] started (pending: 21)\n[#12] rejected EAI_AGAIN after 40068ms (pending: 20)\n\n--- status: started=32 settled=12 pending=20 ---\n```\n\nThe pending count never converges to zero. In a long-running server, this is effectively a memory leak because every queued promise retains references to its enclosing closure.\n\n\n### Additional information\n\n- `UV_THREADPOOL_SIZE` is unset (default 4).\n- The callback-based `dns.lookup()` shows the same behavior — this is a libuv/getaddrinfo issue, not specific to the promises API.\n- Hostnames that fail fast (e.g. `ENOTFOUND`) do not exhibit this problem.\n- The `EAI_AGAIN` timeout (~10s per attempt) appears to come from the system resolver's retry/timeout settings, but the queuing behind the fixed-size thread pool is what makes it unbounded.\n- A possible mitigation from Node's side: support `AbortSignal` in `dns.lookup()` / `dns.promises.lookup()` so callers can cancel stale lookups, or expose a configurable per-lookup timeout.\n","author":{"url":"https://github.com/orgads","@type":"Person","name":"orgads"},"datePublished":"2026-03-30T11:00:47Z","url":"https://github.com/nodejs/node/issues/62503"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:cc0d4979-61e7-8cfa-9dbd-cdc59ad4c9f8 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C25C:2D418D:21DFF1:2F4CF4:6AFBE243 |
| html-safe-nonce | bfcb9a90ada1f5925285a2c6ba0a02ee374787e7d5a3c33aca958244522a2e8b |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDMjVDOjJENDE4RDoyMURGRjE6MkY0Q0Y0OjZBRkJFMjQzIiwidmlzaXRvcl9pZCI6IjE0MjEzMDIxMzcxNDQyMDU4OTEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 0e2c522c38715e326901c4d5754874895f0f376609091d07759bdf7ca9ef1458 |
| hovercard-subject-tag | issue:4169743541 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/nodejs/node/62503/issue_layout |
| twitter:image | https://opengraph.githubassets.com/ca40c96a3077a6997df9290e153d82126005a6e3141451adaabee6cd241c747e/nodejs/node/issues/62503 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/ca40c96a3077a6997df9290e153d82126005a6e3141451adaabee6cd241c747e/nodejs/node/issues/62503 |
| og:image:alt | Version v24.14.1 Platform Linux 6.6.87.2-microsoft-standard-WSL2 x86_64 (Debian forky/sid) Subsystem dns What steps will reproduce the bug? When dns.promises.lookup() is called repeatedly for a hos... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | orgads |
| hostname | github.com |
| expected-hostname | github.com |
| None | 744d4381b1c4dbd6d8736c7d7e5bbe7dc11217584e457a3555020c631764e8ec |
| turbo-cache-control | no-preview |
| go-import | github.com/nodejs/node git https://github.com/nodejs/node.git |
| octolytics-dimension-user_id | 9950313 |
| octolytics-dimension-user_login | nodejs |
| octolytics-dimension-repository_id | 27193779 |
| octolytics-dimension-repository_nwo | nodejs/node |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 27193779 |
| octolytics-dimension-repository_network_root_nwo | nodejs/node |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | df859c48a4c8b4c0009c19bb4e82101aacb4b998 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width