Title: AbortSignal.any(): observed composites still accumulate in a long-lived source's kDependantSignals after #62367 (not GC-pruned) · Issue #64476 · nodejs/node · GitHub
Open Graph Title: AbortSignal.any(): observed composites still accumulate in a long-lived source's kDependantSignals after #62367 (not GC-pruned) · Issue #64476 · nodejs/node
X Title: AbortSignal.any(): observed composites still accumulate in a long-lived source's kDependantSignals after #62367 (not GC-pruned) · Issue #64476 · nodejs/node
Description: Follow-up to #62363 / #62367. #62367 ("defer AbortSignal.any() following") stops listener-less composites from following their sources eagerly. But a composite that is observed (has an abort listener) still follows its sources, and when ...
Open Graph Description: Follow-up to #62363 / #62367. #62367 ("defer AbortSignal.any() following") stops listener-less composites from following their sources eagerly. But a composite that is observed (has an abort listen...
X Description: Follow-up to #62363 / #62367. #62367 ("defer AbortSignal.any() following") stops listener-less composites from following their sources eagerly. But a composite that is observed (has an ab...
Opengraph URL: https://github.com/nodejs/node/issues/64476
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"AbortSignal.any(): observed composites still accumulate in a long-lived source's kDependantSignals after #62367 (not GC-pruned)","articleBody":"Follow-up to #62363 / #62367.\n\n#62367 (\"defer `AbortSignal.any()` following\") stops **listener-less** composites from following their sources eagerly. But a composite that **is** observed (has an `abort` listener) still follows its sources, and when one of those sources is **long-lived**, the composite's entry accumulates in that source's `kDependantSignals` and is **not pruned even by a forced `global.gc()`**. `size` grows monotonically for as long as the process runs.\n\nReproduces on **v24.18.0** (which contains #62367), back on **v22.12.0**, and on the latest **v26.5.0** (`v8 14.6`).\n\n> **Note (edited after #64481):** My original wording said \"aborting or not doesn't matter; both leak\" but only attached the aborted repro. Both cases are shown below now (Repro A = aborted, Repro B = never aborted). They have different causes — see the Update at the bottom.\n\n### Version\n\n`v24.18.0` (`v8 13.6.233.17-node.50`), `v22.12.0` (`v8 12.4.254.21-node.21`), and `v26.5.0` (`v8 14.6.202.34-node.24`).\n\n### Platform\n\nmacOS (darwin), installed via nvm.\n\n### Subsystem\n\n`abortcontroller` / `lib/internal/abort_controller.js`\n\n### Repro A — composite is aborted\n\n```js\n// node --expose-gc reproA.mjs [shared|fresh] (shared = long-lived source)\nconst mode = process.argv[2] || 'shared';\nconst longLived = new AbortController(); // never aborted; e.g. an app-lifetime \"shutdown\" signal\nconst N = 500_000;\n\nconst kDep = () => Object.getOwnPropertySymbols(longLived.signal)\n .find((s) => s.toString() === 'Symbol(kDependantSignals)');\n\nfor (let i = 1; i \u003c= N; i++) {\n const source = mode === 'shared' ? longLived : new AbortController();\n const perReq = new AbortController();\n const composite = AbortSignal.any([perReq.signal, source.signal]);\n composite.addEventListener('abort', () => {}); // \"observed\": composite follows its sources\n perReq.abort(); // settle, then discard composite/perReq\n if (i % 100_000 === 0) {\n globalThis.gc(); // force a full GC\n const sym = kDep();\n console.log(`${i} iters | longLived.kDependantSignals.size = ${sym ? longLived.signal[sym].size : 0}`);\n }\n}\nconsole.log(`node ${process.version} | v8 ${process.versions.v8} | mode=${mode}`);\n```\n\n```\n### mode=shared (long-lived source) ###\n100000 iters | longLived.kDependantSignals.size = 100000\n...\n500000 iters | longLived.kDependantSignals.size = 500000\n\n### mode=fresh (control) ###\n... size = 0 (flat)\n```\n\n### Repro B — composite is never aborted (normal-completion path)\n\n```js\n// node --expose-gc reproB.mjs\nconst longLived = new AbortController();\nconst N = 500_000;\nconst kDep = () => Object.getOwnPropertySymbols(longLived.signal)\n .find((s) => s.toString() === 'Symbol(kDependantSignals)');\n\nfor (let i = 1; i \u003c= N; i++) {\n const perReq = new AbortController();\n const composite = AbortSignal.any([perReq.signal, longLived.signal]);\n composite.addEventListener('abort', () => {}); // observed\n // no abort() — the \"request\" just completes and the composite is dropped\n if (i % 100_000 === 0) {\n globalThis.gc();\n const sym = kDep();\n console.log(`${i} iters | longLived.kDependantSignals.size = ${sym ? longLived.signal[sym].size : 0}`);\n }\n}\nconsole.log(`node ${process.version} | v8 ${process.versions.v8} | never-aborted`);\n```\n\n```\n### v26.5.0 — observed, never aborted ###\n100000 iters | longLived.kDependantSignals.size = 100000\n...\n500000 iters | longLived.kDependantSignals.size = 500000\n```\n\n### Expected behavior\n\nPer the DOM Standard, an `AbortSignal`'s **dependent signals** and **source signals** are each *\"a weak set\"*. Entries for composites that can no longer usefully fire should not accumulate indefinitely on a long-lived source.\n\n### What you see instead\n\n`kDependantSignals.size` on the long-lived source grows monotonically and is not reclaimed by a forced full GC. A fresh-source control (Repro A `mode=fresh`) stays flat at 0.\n\n### Version coverage\n\nBoth repros reproduce on v22.12.0, v24.6.0, v24.13.1, v24.18.0, and v26.5.0.\n\n---\n\n### Update (after #64481)\n\nThanks @bitpshr. The root cause for **Repro A** is `gcPersistentSignals` retaining the aborted composite — the abort path marks it aborted but never drops it, so on a long-lived source it's retained forever and its `WeakRef` never gets pruned. #64481 fixes that by dropping transitively-aborted dependents from `gcPersistentSignals`, which is the clear, actionable bug here.\n\nTo correct my original \"aborting or not doesn't matter\" wording — the two cases differ:\n\n- **Repro A (aborted):** the bug #64481 fixes. ✅\n- **Repro B (never aborted):** still accumulates (verified on v26.5.0 above). But I suspect this one may be **by design**: an observed composite whose source is still alive has to remain reachable so it can fire if the source aborts later, so `gcPersistentSignals` can't drop it while the source lives (cf. #64342). Flagging it only so it's a conscious call whether B is in-scope or expected — if it's expected/\"remove the listener\", that's a fine resolution and #64481 covers the actionable part.\n","author":{"url":"https://github.com/denghongcai","@type":"Person","name":"denghongcai"},"datePublished":"2026-07-13T17:26:45Z","url":"https://github.com/nodejs/node/issues/64476"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf |
| 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:9bfee2db-3e77-cc44-ced7-b236ed696a81 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9688:274790:6B3430:91C591:6AED27E2 |
| html-safe-nonce | 4b7762db8b84bf27874e2fa8ce664819db121acf198880f1aff1224df2bac653 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5Njg4OjI3NDc5MDo2QjM0MzA6OTFDNTkxOjZBRUQyN0UyIiwidmlzaXRvcl9pZCI6IjUxMDE3OTMzNDk3NzczMDM1MjIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 523842fd492353dbe2236296f050bb73ae616f107326f9275a668f183cb9e685 |
| hovercard-subject-tag | issue:4876042889 |
| 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/64476/issue_layout |
| twitter:image | https://opengraph.githubassets.com/08fd181be615791c911d0bfa0369fb5fede916f2de2531fd5b245d31c5983594/nodejs/node/issues/64476 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/08fd181be615791c911d0bfa0369fb5fede916f2de2531fd5b245d31c5983594/nodejs/node/issues/64476 |
| og:image:alt | Follow-up to #62363 / #62367. #62367 ("defer AbortSignal.any() following") stops listener-less composites from following their sources eagerly. But a composite that is observed (has an abort listen... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | denghongcai |
| hostname | github.com |
| expected-hostname | github.com |
| None | 9d95365dda0576efe9b71f45807595e396bd0ca9286fba5367a05048e6ddf8f2 |
| 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 | 98b41fa4b5635ceb45a4c54320fced73817ff290 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width