diff --git a/lib/client.js b/lib/client.js index f237fe02ab8..7d9ec8d7c27 100644 --- a/lib/client.js +++ b/lib/client.js @@ -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() } @@ -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()