stream: fix Writable.destroy performance regression

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 <contact@viniciusl.com.br>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
This commit is contained in:
Robert Nagy 2023-10-26 15:52:53 +02:00 committed by Rich Trott
parent 3daa0a6c04
commit c4decd72f8

View File

@ -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);
}