Skip to content

Commit 241dfaf

Browse files
authored
fix: make assertion a noop (#2111)
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
1 parent 4cda7d5 commit 241dfaf

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

lib/client.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1497,9 +1497,11 @@ function writeStream ({ body, client, request, socket, contentLength, header, ex
14971497
const writer = new AsyncWriter({ socket, request, contentLength, client, expectsPayload, header })
14981498

14991499
const onData = function (chunk) {
1500-
try {
1501-
assert(!finished)
1500+
if (finished) {
1501+
return
1502+
}
15021503

1504+
try {
15031505
if (!writer.write(chunk) && this.pause) {
15041506
this.pause()
15051507
}
@@ -1508,7 +1510,9 @@ function writeStream ({ body, client, request, socket, contentLength, header, ex
15081510
}
15091511
}
15101512
const onDrain = function () {
1511-
assert(!finished)
1513+
if (finished) {
1514+
return
1515+
}
15121516

15131517
if (body.resume) {
15141518
body.resume()

0 commit comments

Comments
 (0)