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 authored and metcoder95 committed Nov 22, 2023
1 parent df10192 commit d2caebb
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 @@ -1977,7 +1977,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 d2caebb

Please sign in to comment.