fix(http): partial response upon stream abort#6936
Closed
theo-sim-dev wants to merge 6 commits intoaxios:v1.xfrom
Closed
fix(http): partial response upon stream abort#6936theo-sim-dev wants to merge 6 commits intoaxios:v1.xfrom
theo-sim-dev wants to merge 6 commits intoaxios:v1.xfrom
Conversation
…ts after headers are received
12b5abb to
47911b7
Compare
47911b7 to
118790e
Compare
| headers: undefined, | ||
| req: undefined, | ||
| chunks: [], | ||
| } |
Check notice
Code scanning / CodeQL
Semicolon insertion Note
Member
|
Closing in favour of #10708 |
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.
Fixes #6935
Context
When a stream emits the
'aborted'event after headers are received, the response object becomes inaccessible, leading to a missingerr.response. This change ensures that key response data, including the body content received so far, is captured early and included in the resulting error object for better error handling and debugging.Fix Summary
status,statusText,headers,req) and incomingdatachunks once headers are received.partialResponse(with body asdata) and attaches it viaAxiosError.from(...)insideresponseStream.on('aborted')andreq.on('error')(if headers were already received)Testing
'should expose partial response on aborted stream', which confirms thaterr.responseincludesstatus,headers, and partialdataSuggestions & Questions
This appears to be the first implementation in Axios that manually preserves and surfaces partial response data for error scenarios where the original response object is inaccessible. I'd appreciate any input on the overall design.
status,statusText,headers,req, anddata. Would there be more fields to capture?isPartial: trueflag in the error response object to denote that the response is incomplete?