Skip to content

lib: fix AbortSignal.any() abort propagation - #66014

Open
inoway46 wants to merge 1 commit into
nodejs:mainfrom
inoway46:codex/fix-abortsignal-any-propagation
Open

lib: fix AbortSignal.any() abort propagation#66014
inoway46 wants to merge 1 commit into
nodejs:mainfrom
inoway46:codex/fix-abortsignal-any-propagation

Conversation

@inoway46

@inoway46 inoway46 commented Sep 13, 2026

Copy link
Copy Markdown
Contributor

Fix AbortSignal.any() losing its abort state when a source is garbage-collected before the composite is observed.

Register dependencies at construction so abort state propagates without listeners, while preserving existing WeakRef and timeout cleanup.

In a 2-million-iteration churn test on macOS x64, RSS increased from ~52 MiB to 113–124 MiB without linear growth. After GC, dependent entries were zero and heap usage was ~4 MiB in both runs.

Fixes: #65995
Refs: #62363

Follow composite signal sources at construction so abort state is
propagated even without listeners, before sources can be collected.
Keep the existing weak-reference finalization and timeout cleanup.

Cover source collection before each state accessor, including nested
composites, and cleanup of unreachable listener-less dependents.

Fixes: nodejs#65995
Refs: nodejs#62363
Assisted-by: Codex
Signed-off-by: inoway46 <inoueyuya416@gmail.com>
@nodejs-github-bot nodejs-github-bot added the needs-ci PRs that need a full CI run. label Sep 13, 2026
@inoway46
inoway46 marked this pull request as ready for review September 13, 2026 11:14
@inoway46 inoway46 added the abortcontroller Issues and PRs related to the AbortController and AbortSignal APIs. label Sep 13, 2026
@codecov

codecov Bot commented Sep 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.00%. Comparing base (4521f26) to head (d0e9e7d).
⚠️ Report is 13 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #66014      +/-   ##
==========================================
- Coverage   90.01%   90.00%   -0.01%     
==========================================
  Files         785      785              
  Lines      269282   269330      +48     
  Branches    51288    51305      +17     
==========================================
+ Hits       242381   242418      +37     
- Misses      17401    17411      +10     
- Partials     9500     9501       +1     
Files with missing lines Coverage Δ
lib/internal/abort_controller.js 95.40% <100.00%> (-0.59%) ⬇️

... and 31 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

abortcontroller Issues and PRs related to the AbortController and AbortSignal APIs. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AbortSignal.any() can lose an abort when its source is garbage-collected

4 participants