Repository navigation
Abort requests with the signal passed to them - #112
Merged
Merged
Conversation
fetchf() replaced the signal passed to a request with the one it uses for timeouts and cancellation, so aborting it had no effect. Its abort is now forwarded to the request, which isn't sent at all when the signal is aborted already, and fails with the reason of the abort like fetch() does. Aborted requests are no longer retried, and polling stops as soon as the signal is aborted, as its waits now end early.
Core bundles 7.75 KB -> 8.75 KB, dist/react/index.mjs 10.75 KB -> 11.75 KB and dist/react/index.js 11.75 KB -> 12.75 KB. The limits fit this and the other PRs opened alongside it (abort signal fix, ETag revalidation, retry jitter and methods, onDownloadProgress, responseType, focusThrottleInterval, initialData and typed OpenAPI endpoints), which add about 1 KB together, so that they can be merged in any order.
size-limit report 📦
|
MattCCC
commented
Sep 27, 2026
…to the signal The signal is known to be set inside the if block, so the optional chaining added a branch that can never run, which failed the 100% branch coverage threshold. AbortSignal has addEventListener wherever fetchff runs, e.g. in Node.js 18+ and browsers.
red-game-dev
approved these changes
Sep 27, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request fixes the
signalsetting, which had no effect:fetchf()replaced the signal passed to a request with the one it uses for timeouts and cancellation, so aborting it neither cancelled the request nor stopped its retries or polling.🐛 Bug Fixes
fetch(). Aborting withcontroller.abort()cancels it likecancellabledoes, so its promise is only rejected withrejectCancelled: true, while a custom reason, e.g. the timeout ofAbortSignal.timeout(), makes it fail with that reason.cancellableone or withabortRequest(). Before, a retry of a request cancelled by a newer one could cancel the newer one in turn.createApiFetcher()endpoints, e.g.api.getReport({ signal }).signalsetting in the Request Cancellation section.Aborted requests are not retried anymore, even when
shouldRetrywould retry them. Timeouts aren't affected, so they are still retried according toretryOnandshouldRetry.🧪 Tests
rejectCancelled, custom abort reasons, the timeout of the request, and that requests stop listening to the signal once they are done.createApiFetcher()endpoints, anddelayInvocation()ending early when its signal is aborted.📦 Bundle Size
The core bundles grow by about 0.1 KB (brotli). The size limits are raised to fit this and the other pull requests opened alongside it, so that they can be merged in any order.
Generated by Claude Code