Commit e8c279d731f for nodejs
commit e8c279d731f2c0eb6eaff03cd341fad469498107
Author: James M Snell <jasnell@gmail.com>
Date: Fri Nov 20 08:48:04 2026 -0800
lib: avoid using __proto__: null in AbortController/AbortSignal
Using `__proto__: null` on objects will properties immediately
puts them into the slower DictionaryProperties mode. Using a
`__proto__: { __proto: null }, ...` pattern, however, keeps
the objects in FastProperties mode.
Technically this is an observable change since calling
`Object.getPrototoTypeOf(...)` some of these will no longer
return `null`. So a decision needs to be made about whether
these types of changes are `semver-major` or not.
Signed-off-by: James M Snell <jasnell@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/66678
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Ulises Gascón <ulisesgascongonzalez@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
diff --git a/lib/internal/abort_controller.js b/lib/internal/abort_controller.js
index 3b0f70a58b3..b47af84a598 100644
--- a/lib/internal/abort_controller.js
+++ b/lib/internal/abort_controller.js
@@ -33,6 +33,7 @@ const {
const { kMaxEventTargetListeners } = require('events');
const {
customInspectSymbol,
+ kEmptyObject,
kEnumerableProperty,
} = require('internal/util');
const { inspect } = require('internal/util/inspect');
@@ -354,7 +355,7 @@ class AbortSignal extends EventTarget {
static any(signals) {
const signalsArray = converters['sequence<AbortSignal>'](
signals,
- { __proto__: null, context: 'signals' },
+ { __proto__: kEmptyObject, context: 'signals' },
);
const resultSignal = new AbortSignal(kDontThrowSymbol, false, undefined, false, true);
@@ -458,7 +459,7 @@ class AbortSignal extends EventTarget {
if (aborted) {
const reason = this.reason;
return {
- data: { aborted, reason },
+ data: { __proto__: kEmptyObject, aborted, reason },
deserializeInfo: 'internal/abort_controller:ClonedAbortSignal',
};
}
@@ -469,10 +470,10 @@ class AbortSignal extends EventTarget {
this.addEventListener('abort', () => {
port1.postMessage(this.reason);
port1.close();
- }, { once: true });
+ }, { __proto__: kEmptyObject, once: true });
return {
- data: { port: port2 },
+ data: { __proto__: kEmptyObject, port: port2 },
deserializeInfo: 'internal/abort_controller:ClonedAbortSignal',
};
}
@@ -665,12 +666,12 @@ function transferableAbortController() {
* @returns {Promise<void>}
*/
async function aborted(signal, resource) {
- converters.AbortSignal(signal, { __proto__: null, context: 'signal' });
+ converters.AbortSignal(signal, { __proto__: kEmptyObject, context: 'signal' });
validateObject(resource, 'resource', kValidateObjectAllowObjects);
if (signal.aborted)
return PromiseResolve();
const abortPromise = PromiseWithResolvers();
- const opts = { __proto__: null, [kWeakHandler]: resource, once: true, [kResistStopPropagation]: true };
+ const opts = { __proto__: kEmptyObject, [kWeakHandler]: resource, once: true, [kResistStopPropagation]: true };
signal.addEventListener('abort', abortPromise.resolve, opts);
return abortPromise.promise;
}