From c6d81d9ab0caf74a97f93ee10659494c13d68b70 Mon Sep 17 00:00:00 2001 From: Roberto Bianchi Date: Mon, 30 Nov 2026 15:14:55 +0100 Subject: [PATCH] http2: avoid mutable push on private arrays The pending request callbacks of a connecting client session and the single-value header names tracked by buildNgHeaderString() were collected with .push() on private arrays, which looks up Array.prototype.push at call time. Replacing that method from user code changed how these paths ran. Use indexed assignments instead. Signed-off-by: Roberto Bianchi --- lib/internal/http2/core.js | 5 +++-- lib/internal/http2/util.js | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/internal/http2/core.js b/lib/internal/http2/core.js index 2290af5d998..2c6cc25f49f 100644 --- a/lib/internal/http2/core.js +++ b/lib/internal/http2/core.js @@ -2062,8 +2062,9 @@ class ClientHttp2Session extends Http2Session { const onConnect = reqAsync.bind( requestOnConnect.bind(stream, headersList, options)); if (this.connecting) { - if (this[kPendingRequestCalls] !== null) { - this[kPendingRequestCalls].push(onConnect); + const pendingCalls = this[kPendingRequestCalls]; + if (pendingCalls !== null) { + pendingCalls[pendingCalls.length] = onConnect; } else { this[kPendingRequestCalls] = [onConnect]; this.once('connect', () => { diff --git a/lib/internal/http2/util.js b/lib/internal/http2/util.js index ab50ef48b15..4c29214d28e 100644 --- a/lib/internal/http2/util.js +++ b/lib/internal/http2/util.js @@ -817,7 +817,7 @@ function buildNgHeaderString(arrayOrMap, } else if (singles.includes(key)) { throw new ERR_HTTP2_HEADER_SINGLE_VALUE(key); } else { - singles.push(key); + singles[singles.length] = key; } } const flags = neverIndex.length !== 0 && neverIndex.includes(key) ?