Commit 270d4f36514 for nodejs

commit 270d4f36514fad029e78582213d53a45cf8cc0f0
Author: Roberto Bianchi <roberto.bianchi@spendesk.com>
Date:   Thu Nov 26 17:03:37 2026 +0100

    stream: avoid mutable push in writable end callbacks

    Writable.prototype.end() queued its callback with .push() on a private
    array, which looks up Array.prototype.push at call time. Replacing that
    method from user code made end() throw or drop the callback. Use an
    indexed assignment instead.

    Signed-off-by: Roberto Bianchi <roberto.bianchi@spendesk.com>
    PR-URL: https://github.com/nodejs/node/pull/67751
    Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
    Reviewed-By: René <contact.9a5d6388@renegade334.me.uk>
    Reviewed-By: Jordan Harband <ljharb@gmail.com>
    Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
    Reviewed-By: Luigi Pinca <luigipinca@gmail.com>

diff --git a/lib/internal/streams/writable.js b/lib/internal/streams/writable.js
index 3f62489c0f7..0ab27342199 100644
--- a/lib/internal/streams/writable.js
+++ b/lib/internal/streams/writable.js
@@ -903,8 +903,8 @@ Writable.prototype.end = function(chunk, encoding, cb) {
       process.nextTick(cb, null);
     } else {
       state[kState] |= kOnFinished;
-      state[kOnFinishedValue] ??= [];
-      state[kOnFinishedValue].push(cb);
+      const onFinished = state[kOnFinishedValue] ??= [];
+      onFinished[onFinished.length] = cb;
     }
   }