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 crysmags committed Feb 27, 2024
1 parent 7fc4e69 commit 4cb9bc2
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 4cb9bc2

Please sign in to comment.