From dbeb6e49bb96f398339f0b0588aa8edb28a38e95 Mon Sep 17 00:00:00 2001 From: Yaroslav Chuhai Date: Mon, 23 Nov 2026 18:36:38 +0100 Subject: [PATCH] url: keep urlToHttpOptions() result in fast mode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit urlToHttpOptions() built its result with `__proto__: null` ahead of a spread, which makes V8 create the object in dictionary mode. Every http.request() and https.request() called with a string or URL goes through it, and ClientRequest immediately copies the result, so both the property stores and the copy took the slow path. Use `__proto__: kEmptyObject` instead, as ClientRequest already does for its option copies. The object stays in fast mode and still inherits nothing. Signed-off-by: Yaroslav Chuhai PR-URL: https://github.com/nodejs/node/pull/67683 Reviewed-By: Gürgün Dayıoğlu Reviewed-By: René Reviewed-By: James M Snell --- lib/internal/url.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/internal/url.js b/lib/internal/url.js index 682c502e4cb..1c4f45a4ea9 100644 --- a/lib/internal/url.js +++ b/lib/internal/url.js @@ -1480,7 +1480,7 @@ function urlToHttpOptions(url) { validateObject(url, 'url', kValidateObjectAllowObjects); const { hostname, pathname, port, username, password, search } = url; const options = { - __proto__: null, + __proto__: kEmptyObject, // Only spread own enumerable properties for genuine WHATWG URL instances so // that a URL object can still be extended with additional request options // (e.g. `url.headers = ...`). Arbitrary duck-typed objects accepted by