feat(helpers): modernize composeSignals with AbortSignal.any support#7380
feat(helpers): modernize composeSignals with AbortSignal.any support#7380Divyapahuja31 wants to merge 3 commits into
Conversation
|
Thanks for the work on this. I dug into it and unfortunately there's a regression I don't think we can land as-is. The existing implementation wraps every incoming abort reason. Anything that isn't already an
A correct version needs to keep the wrapping. Roughly: use Going to close this in favor of an issue so it can be picked up with the wrapping preserved and a regression test for the |
Description
This PR modernizes the composeSignals helper by leveraging the native
AbortSignal.any()API when it is available in the environment (Node.js 20+, modern browsers).Key Changes
AbortSignal.any()to create a composite signal from multiple input signals and/or a timeout. This is more efficient and cleaner than the manual event listener attachment approach used previously.AbortSignal.any.Testing
I have verified these changes locally to ensure no regressions:
Checklist
Summary by cubic
Modernizes
composeSignalsto useAbortSignal.anywhen available, simplifying signal composition and ensuring proper timeout cleanup. Keeps a safe fallback for older runtimes and matches fetch adapter expectations.New Features
AbortSignal.anyto combine input signals and an optional timeout in supported environments.compositeSignal.unsubscribeto clear timeout timers.Testing
composeSignalsand fetch adapter tests pass, including after the latestv1.xmerge.AbortSignal.anypath.Written for commit 64f76e0. Summary will update on new commits.