From 5c8de42ccb97e75f5b6107acfeaacdc386a9196f Mon Sep 17 00:00:00 2001 From: Robert Nagy Date: Thu, 26 Oct 2023 15:52:53 +0200 Subject: [PATCH] stream: fix Writable.destroy performance regression MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ref: https://github.com/nodejs/node/pull/50409 PR-URL: https://github.com/nodejs/node/pull/50478 Reviewed-By: Vinícius Lourenço Claro Cardoso Reviewed-By: Antoine du Hamel --- lib/internal/streams/writable.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/internal/streams/writable.js b/lib/internal/streams/writable.js index 17fc7bbbbf5b65..e55ddc1796cf6c 100644 --- a/lib/internal/streams/writable.js +++ b/lib/internal/streams/writable.js @@ -1105,7 +1105,7 @@ Writable.prototype.destroy = function(err, cb) { const state = this._writableState; // Invoke pending callbacks. - if ((state[kState] & (kBuffered | kOnFinished | kDestroyed)) !== kDestroyed) { + if ((state[kState] & (kBuffered | kOnFinished)) !== 0 && (state[kState] & kDestroyed) === 0) { process.nextTick(errorBuffer, state); }