Repository navigation
lib: defer AbortSignal.any() following - #62367
Merged
nodejs-github-bot merged 5 commits intoApr 2, 2026
Merged
Conversation
Avoid registering AbortSignal.any() composites as dependants until they are actually observed. This fixes the long-lived source retention pattern from nodejs#62363 while preserving abort semantics through lazy refresh and follow paths. Also unregister fired timeout signals from the timeout finalization registry so timeout churn releases memory more promptly.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #62367 +/- ##
==========================================
- Coverage 91.60% 89.68% -1.92%
==========================================
Files 337 676 +339
Lines 140745 206752 +66007
Branches 21802 39593 +17791
==========================================
+ Hits 128925 185433 +56508
- Misses 11595 13465 +1870
- Partials 225 7854 +7629
🚀 New features to boost your workflow:
|
geeksilva97
approved these changes
Mar 22, 2026
Contributor
|
cc @atlowChemi |
Summary
AbortSignal.any()until the composite is observedclearTimeoutRegistryto reduce timeout churn retentionProblem
AbortSignal.any()eagerly registered listener-less composites as dependants of their source signals. With a long-lived source, repeatedAbortSignal.any([source])calls accumulated inkDependantSignalsand retained memory (#62363).While investigating broader
AbortSignalchurn, timeout-only churn also kept timeout finalization registry entries alive after timers had fired, which delayed cleanup.What Changed
AbortSignal.any()aborted,reason, orthrowIfAborted()AbortSignal.timeout()clearTimeoutRegistryResults
#62363reproout/Release/nodestayed flat through 2,000,000 iterationskDependantSignalsstayed at0Timeout churn
AbortSignal.timeout(1)after GCrss 164.55 MiB,heap 23.15 MiBrss 67.19 MiB,heap 3.96 MiBAbortSignal.any([AbortSignal.timeout(1)])after GCrss 135.30 MiB,heap 7.85 MiBrss 74.22 MiB,heap 4.01 MiBTimeout churn logs
Before patch
With patch
Notes
The same-tick fresh
AbortControllermicrobenchmark from #54614 still shows heap growth until the next turn. That appears to be due toWeakRefcleanup semantics rather than long-lived source retention: the heap drops back after asetImmediate()and the weak references clear on the next turn.Testing
python3 tools/test.py test/parallel/test-abortsignal-any.mjs test/parallel/test-abort-controller-any-timeout.js test/parallel/test-abortsignal-drop-settled-signals.mjs test/parallel/test-abortsignal-timeout-memory.js test/parallel/test-abortcontroller.jsFixes: #62363
Refs: #54614