fix: unsettled promise when request is aborted and compression is used and maxRedirects is set to 0 #7149
+22
−1
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 axios request is left in an unsettled state (waits forever) when using compression and maxRedirects is set to 0 and the request gets aborted after some chunks are sent.
The problem is that the response
abortevent is not being emitted and the request state inside theresponseStream.on('error')callback isdestroyed: true, aborted: false.I see that previoysly axios was checking
req.abortedinstead ofreq.destroyedinside theresponseStream.on('error')callback, but since node deprecated thereq.aborted, it was changed toreq.destroyedin #4787.We could change that back to
req.aborted, but I think checkingrejectedwould be a better option, so we can be sure that we are catching all the errors (in case there are some more weird cases).Failing tests before: