Commit be1b3d62cfe for nodejs
commit be1b3d62cfe66faba2e98ce273d658a00584b273
Author: Yaroslav Chuhai <yaroslavchugai@gmail.com>
Date: Mon Nov 23 18:36:38 2026 +0100
url: keep urlToHttpOptions() result in fast mode
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 <yaroslavchuhai@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/67683
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
Reviewed-By: René <contact.9a5d6388@renegade334.me.uk>
Reviewed-By: James M Snell <jasnell@gmail.com>
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