Skip to content

Commit

Permalink
fix: delay abort on 'close' (#2408)
Browse files Browse the repository at this point in the history
Some legacy streams will incorrectly emit 'close' before 'end' in
the successfull case.
  • Loading branch information
ronag committed Nov 8, 2023
1 parent a593323 commit 57fd343
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -1972,7 +1972,11 @@ function writeStream ({ h2stream, body, client, request, socket, contentLength,
}
}
const onAbort = function () {
onFinished(new RequestAbortedError())
if (finished) {
return
}
const err = new RequestAbortedError()
queueMicrotask(() => onFinished(err))
}
const onFinished = function (err) {
if (finished) {
Expand Down

0 comments on commit 57fd343

Please sign in to comment.