Skip to content

fix: preserve Request signal abort propagation after GC#4984

Draft
mcollina wants to merge 2 commits intomainfrom
fix/request-signal-gc
Draft

fix: preserve Request signal abort propagation after GC#4984
mcollina wants to merge 2 commits intomainfrom
fix/request-signal-gc

Conversation

@mcollina
Copy link
Copy Markdown
Member

@mcollina mcollina commented Apr 6, 2026

Summary

Fix Request signal following so abort propagation still works after GC pressure.

This replaces the custom WeakRef/FinalizationRegistry-based follow logic in lib/web/fetch/request.js with AbortSignal.any([signal]).

Changes

  • use AbortSignal.any([signal]) to create dependent request signals
  • add a regression test for a Request signal surviving GC pressure
  • add a regression test for cloned Request signals surviving GC pressure
  • add a regression test to ensure reusing a controller across transient requests does not emit listener leak warnings

Motivation

This reproduces the behavior discussed in:

The old implementation could disconnect request.signal from its parent signal once the original Request object became unreachable. As a result, aborting the parent signal no longer aborted the dependent request signal.

Testing

  • NODE_OPTIONS=--expose-gc node --test test/fetch/request.js
  • NODE_OPTIONS=--expose-gc node --test test/fetch/long-lived-abort-controller.js test/node-fetch/request.js test/fetch/abort.js

mcollina added 2 commits April 6, 2026 15:30
Signed-off-by: Matteo Collina <hello@matteocollina.com>
Signed-off-by: Matteo Collina <hello@matteocollina.com>
@codecov-commenter
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.95%. Comparing base (bbd66d0) to head (ca4c9bc).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4984   +/-   ##
=======================================
  Coverage   92.95%   92.95%           
=======================================
  Files         110      110           
  Lines       35773    35680   -93     
=======================================
- Hits        33252    33166   -86     
+ Misses       2521     2514    -7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants