From 3afa881241d927bb9fe46d012798a05fdc6a4383 Mon Sep 17 00:00:00 2001 From: "Mark S. Miller" Date: Sun, 24 Jul 2022 05:09:29 -0700 Subject: [PATCH] process: use `defineProperty` instead of assignment PR-URL: https://github.com/nodejs/node/pull/43907 Fixes: https://github.com/nodejs/node/issues/43496 Refs: https://github.com/endojs/endo/issues/576 Reviewed-By: Antoine du Hamel Reviewed-By: Mestery --- lib/internal/process/per_thread.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/internal/process/per_thread.js b/lib/internal/process/per_thread.js index 709bcb7b137639..f80d078444047c 100644 --- a/lib/internal/process/per_thread.js +++ b/lib/internal/process/per_thread.js @@ -15,6 +15,7 @@ const { Float64Array, NumberMAX_SAFE_INTEGER, ObjectFreeze, + ObjectDefineProperty, ReflectApply, RegExpPrototypeTest, SafeArrayIterator, @@ -371,9 +372,15 @@ function buildAllowedFlags() { return SetPrototypeValues(this[kInternal].set); } } - NodeEnvironmentFlagsSet.prototype.keys = - NodeEnvironmentFlagsSet.prototype[SymbolIterator] = - NodeEnvironmentFlagsSet.prototype.values; + const flagSetValues = NodeEnvironmentFlagsSet.prototype.values; + ObjectDefineProperty(NodeEnvironmentFlagsSet.prototype, SymbolIterator, { + __proto__: null, + value: flagSetValues, + }); + ObjectDefineProperty(NodeEnvironmentFlagsSet.prototype, 'keys', { + __proto__: null, + value: flagSetValues, + }); ObjectFreeze(NodeEnvironmentFlagsSet.prototype.constructor); ObjectFreeze(NodeEnvironmentFlagsSet.prototype);