Skip to content

Commit 30bec50

Browse files
committed
lib: make process.moduleLoadList a copy of the internal value
process.moduleLoadList was provided as-is instead of a copy of it Refs: nodejs#41233 Refs: nodejs#61276
1 parent 650f51f commit 30bec50

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

lib/internal/bootstrap/realm.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,9 @@ const {
7474
const moduleLoadList = [];
7575
ObjectDefineProperty(process, 'moduleLoadList', {
7676
__proto__: null,
77-
value: moduleLoadList,
78-
configurable: true,
77+
get() { return ArrayPrototypeSlice(moduleLoadList); },
7978
enumerable: true,
80-
writable: false,
79+
configurable: true,
8180
});
8281

8382

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
'use strict';
2+
3+
require('../common');
4+
const assert = require('assert');
5+
6+
assert.ok(Array.isArray(process.moduleLoadList));
7+
assert.throws(() => process.moduleLoadList = 'foo', /^TypeError: Cannot set property moduleLoadList of #<process> which has only a getter$/);

0 commit comments

Comments
 (0)