Skip to content

Conversation

@gyx1000
Copy link

@gyx1000 gyx1000 commented Nov 27, 2025

This relates to #4068

Changes

This PR fixes an issue where cloning a Request caused the cloned instance to lose its AbortSignal behavior under certain GC conditions.
The underlying problem was that the signal reference could be garbage-collected prematurely, preventing the abort event from propagating to the cloned request. This resulted in inconsistent abort behavior on the very first request processed after a clone.

The fix ensures the signal and its abort listener remain properly retained across clones, restoring consistent abort propagation for cloned Request objects.

Bug Fixes

  • Fixed a bug where Request.clone() or new Request(request), could drop the associated AbortSignal listener during garbage collection.
  • Ensured cloned Request objects consistently propagate abort events, including during the initial request lifecycle.

Status

  • I have read and agreed to the [Developer's Certificate of Origin][cert]
  • Tested
  • Benchmarked (optional)
  • Documented
  • Review ready
  • In review
  • Merge ready

Copy link
Member

@KhafraDev KhafraDev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My comment in the original issue makes it seem like this is not an issue in undici.

@codecov-commenter
Copy link

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.85%. Comparing base (fdafc2a) to head (b3445e4).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4678      +/-   ##
==========================================
- Coverage   92.86%   92.85%   -0.02%     
==========================================
  Files         107      107              
  Lines       33499    33517      +18     
==========================================
+ Hits        31108    31121      +13     
- Misses       2391     2396       +5     

☔ 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.

@tsctx
Copy link
Member

tsctx commented Nov 28, 2025

My comment in the original issue makes it seem like this is not an issue in undici.

It's undici that is the problem, not node.

Once the parent signal is garbage collected, the child loses its reference and therefore cannot propagate the abort signal, even if the original signal is aborted.

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.

4 participants