Skip to content

Commit

Permalink
fix: make assertion a noop (nodejs#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: nodejs#2109
  • Loading branch information
ronag authored and metcoder95 committed Jul 21, 2023
1 parent 4e6e54e commit 870b30f
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 870b30f

Please sign in to comment.