fix(fetch): cancel request.body instead of source stream#10702
Merged
jasonsaayman merged 1 commit intoaxios:v1.xfrom Apr 13, 2026
Merged
fix(fetch): cancel request.body instead of source stream#10702jasonsaayman merged 1 commit intoaxios:v1.xfrom
jasonsaayman merged 1 commit intoaxios:v1.xfrom
Conversation
Member
|
Thanks @zoontek! |
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.
The
Requestconstructor extracts and locks theReadableStreampassed as body, so callingcancel()on the original reference rejects with aTypeErrorper spec. This PR cancels the transferred stream viarequest.bodyinstead, which achieves the same goal without producing an unhandled rejection.Related #7515
Fixes expo/expo#44382
Summary by cubic
Cancel the transferred request body (
request.body) in thefetchadapter’s request stream probe to avoid TypeErrors from cancelling the original source stream. This removes unhandled rejections while keeping the probe behavior the same.Description
lib/adapters/fetch.js, create theRequestwith a newReadableStream, then cancelrequest.body(if present) instead of the original stream.duplexaccess check andContent-Typeheader probe unchanged.Requestconstructor locks the passed stream; cancelling the original throws a TypeError.request.bodyachieves the same effect without errors.Docs
Testing
Request.Written for commit eec1e42. Summary will update on new commits.