Repository navigation
Add onDownloadProgress to track the download progress of responses - #115
Merged
Merged
Conversation
…se bodies onDownloadProgress is called with the loaded and total bytes and the progress from 0 to 1 whenever a part of a response body arrives. The body of native responses is counted while it's received and parsed, so it works wherever fetch() streams response bodies, including responses parsed by a custom parser. The total comes from the Content-Length header, and is unknown for compressed responses, whose Content-Length is the compressed size. The progress never goes beyond 1, as browsers may hide the Content-Encoding header of cross-origin responses. Responses without a body and responses of custom fetchers that aren't native are left as they are.
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 📦
|
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 adds
onDownloadProgress, the counterpart ofonUploadProgress, to track the progress of a response body while it's being received, e.g. to show a progress bar for file downloads.✨ Features & Improvements
onDownloadProgress: it's called withloaded(the bytes received so far),total(the bytes to receive, if known) andprogress(from0to1, if the total is known) whenever a part of the response body arrives.fetch()streams response bodies, i.e. in all modern browsers, Node.js, Deno and Bun, and also for bodies read by a customparser.Content-Lengthheader, and unknown for compressed responses, whoseContent-Lengthis the compressed size. The progress never goes beyond1, e.g. when browsers hide theContent-Encodingheader of cross-origin responses.redirectedandtype. Responses without a body and responses of custom fetchers that aren't nativeResponseobjects are left as they are.DownloadProgresstype.🧪 Tests
Content-Lengthand for compressed responses, and a progress that doesn't go beyond1.onDownloadProgress.📦 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