Title: AbortSignal.any memory leak when circular dependencies · Issue #57584 · nodejs/node · GitHub
Open Graph Title: AbortSignal.any memory leak when circular dependencies · Issue #57584 · nodejs/node
X Title: AbortSignal.any memory leak when circular dependencies · Issue #57584 · nodejs/node
Description: Version 23.10.0 Platform 6.8.0-55-generic #57-Ubuntu SMP PREEMPT_DYNAMIC Wed Feb 12 23:42:21 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux Subsystem No response What steps will reproduce the bug? class Test { private abortController = new Abor...
Open Graph Description: Version 23.10.0 Platform 6.8.0-55-generic #57-Ubuntu SMP PREEMPT_DYNAMIC Wed Feb 12 23:42:21 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux Subsystem No response What steps will reproduce the bug? class T...
X Description: Version 23.10.0 Platform 6.8.0-55-generic #57-Ubuntu SMP PREEMPT_DYNAMIC Wed Feb 12 23:42:21 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux Subsystem No response What steps will reproduce the bug? class T...
Opengraph URL: https://github.com/nodejs/node/issues/57584
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"AbortSignal.any memory leak when circular dependencies","articleBody":"### Version\n\n23.10.0\n\n### Platform\n\n```text\n6.8.0-55-generic #57-Ubuntu SMP PREEMPT_DYNAMIC Wed Feb 12 23:42:21 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux\n```\n\n### Subsystem\n\n_No response_\n\n### What steps will reproduce the bug?\n\n```typescript\nclass Test {\n private abortController = new AbortController()\n\n public test(cb: (abortSignal: AbortSignal) => void, abortSignal: AbortSignal) {\n const signal = AbortSignal.any([abortSignal, this.abortController.signal])\n\n cb(signal)\n }\n}\n\nconst registry = new FinalizationRegistry((heldValue) => {\n console.log(`${heldValue} has been collected`)\n})\n\n;(() => {\n const test = new Test()\n registry.register(test, 'test')\n\n const abortController = new AbortController()\n\n test.test((abortSignal) => {\n abortSignal.addEventListener('abort', () => {\n console.log(test)\n })\n }, abortController.signal)\n})()\n\nglobal.gc?.()\n\nsetTimeout(() => {\n console.log('the end')\n}, 2000)\n```\n\nrun with `node --expose-gc test.ts`\n\n### How often does it reproduce? Is there a required condition?\n\nEvery time\n\n### What is the expected behavior? Why is that the expected behavior?\n\nthe output should be \n```\ntest has been collected\nthe end\n```\nbecause the test object is not referenced anymore\n\n### What do you see instead?\n\noutput:\n```\nthe end\n```\n\nthe test object is not garbage collected\n\n### Additional information\n\nThe issues seems to be caused by the cyclic dependency: `test` object => `abortController` field => `abortSignal` => `AbortSignal.any` result => `cb` function => `test` object\n\nAbortSignal.any seems to prevent node from garbage collecting them all at once","author":{"url":"https://github.com/CGNonofr","@type":"Person","name":"CGNonofr"},"datePublished":"2025-03-21T18:09:32Z","url":"https://github.com/nodejs/node/issues/57584"}
| 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:853cdad5-add8-57c9-2f7a-ddee1fe4b512 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CC0E:1B6988:1554B4:1E7F50:6AFB15B5 |
| html-safe-nonce | b5a1a59eacb4b156afc63e045009271fe788a24fc1e3a9de083caedbc17dde45 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDQzBFOjFCNjk4ODoxNTU0QjQ6MUU3RjUwOjZBRkIxNUI1IiwidmlzaXRvcl9pZCI6IjE2NDY0NjMxODYyOTY4Mzc1NTciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 1702cc536711de9c73a4ccb912128d83d0ad645a1e94aebbb6cbb9bc5339e2a6 |
| hovercard-subject-tag | issue:2939149260 |
| 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/57584/issue_layout |
| twitter:image | https://opengraph.githubassets.com/78e15aaee13446eba3864b47031d411f49c2f1037a531175e9aef194b98e3043/nodejs/node/issues/57584 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/78e15aaee13446eba3864b47031d411f49c2f1037a531175e9aef194b98e3043/nodejs/node/issues/57584 |
| og:image:alt | Version 23.10.0 Platform 6.8.0-55-generic #57-Ubuntu SMP PREEMPT_DYNAMIC Wed Feb 12 23:42:21 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux Subsystem No response What steps will reproduce the bug? class T... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | CGNonofr |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4275ec98d19a530a209480d02854be81de24ad5a05b648333242fc516bfb573c |
| 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 | ba13208acc32a4e7a4a3b54cb2f0dea6001ba5f8 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width