Skip to content

Commit

Permalink
fix: make assertion a noop (#2111)
Browse files Browse the repository at this point in the history
Not sure how this can occur. I'm guessing if 'finished' and 'drain' are both queued
then onDrain will be invoked even though event listeners have been removed.

Fixes: #2109
  • Loading branch information
ronag committed May 8, 2023
1 parent 4cda7d5 commit 241dfaf
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lib/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -1497,9 +1497,11 @@ function writeStream ({ body, client, request, socket, contentLength, header, ex
const writer = new AsyncWriter({ socket, request, contentLength, client, expectsPayload, header })

const onData = function (chunk) {
try {
assert(!finished)
if (finished) {
return
}

try {
if (!writer.write(chunk) && this.pause) {
this.pause()
}
Expand All @@ -1508,7 +1510,9 @@ function writeStream ({ body, client, request, socket, contentLength, header, ex
}
}
const onDrain = function () {
assert(!finished)
if (finished) {
return
}

if (body.resume) {
body.resume()
Expand Down

0 comments on commit 241dfaf

Please sign in to comment.