From 5abd9baea8e6a33c04afd7cfde73c83cfc560a47 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 631348dcd3af69..c2be274659e6c7 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, RegExpPrototypeExec, 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);