Skip to content

Commit c7993ad

Browse files
committed
src: remove experimental ShadowRealm support
The TC39 ShadowRealm proposal remains unimplemented by browsers, and WPT removed ShadowRealm test coverage. Remove the Node.js host integration, the --experimental-shadow-realm CLI flag, and related tests. Refs: web-platform-tests/wpt#59794 Refs: #42528 Signed-off-by: Yagiz Nizipli <yagiz@nizipli.com> Co-authored-by: Yagiz Nizipli <anonrig@users.noreply.github.com>
1 parent f83e7df commit c7993ad

53 files changed

Lines changed: 23 additions & 782 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎doc/api/cli.md‎

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1425,16 +1425,6 @@ Use this flag to generate a blob that can be injected into the Node.js
14251425
binary to produce a [single executable application][]. See the documentation
14261426
about [this configuration][`--experimental-sea-config`] for details.
14271427

1428-
### `--experimental-shadow-realm`
1429-
1430-
<!-- YAML
1431-
added:
1432-
- v19.0.0
1433-
- v18.13.0
1434-
-->
1435-
1436-
Use this flag to enable [ShadowRealm][] support.
1437-
14381428
### `--experimental-storage-inspection`
14391429

14401430
<!-- YAML
@@ -3881,7 +3871,6 @@ one is included in the list below.
38813871
* `--experimental-print-required-tla`
38823872
* `--experimental-quic`
38833873
* `--experimental-require-module`
3884-
* `--experimental-shadow-realm`
38853874
* `--experimental-specifier-resolution`
38863875
* `--experimental-stream-iter`
38873876
* `--experimental-test-isolation`
@@ -4377,8 +4366,6 @@ documented here:
43774366

43784367
### `--expose-gc`
43794368

4380-
### `--harmony-shadow-realm`
4381-
43824369
### `--heap-snapshot-on-oom`
43834370

43844371
### `--interpreted-frames-native-stack`
@@ -4484,7 +4471,6 @@ node --stack-trace-limit=12 -p -e "Error.stackTraceLimit" # prints 12
44844471
[Permission Model]: permissions.md#permission-model
44854472
[REPL]: repl.md
44864473
[ScriptCoverage]: https://chromedevtools.github.io/devtools-protocol/tot/Profiler#type-ScriptCoverage
4487-
[ShadowRealm]: https://github.com/tc39/proposal-shadowrealm
44884474
[Source Map]: https://tc39.es/ecma426/
44894475
[Test tags]: test.md#test-tags
44904476
[TypeScript type-stripping]: typescript.md#type-stripping

‎doc/node-config-schema.json‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -252,10 +252,6 @@
252252
"type": "boolean",
253253
"description": "Legacy alias for --require-module"
254254
},
255-
"experimental-shadow-realm": {
256-
"type": "boolean",
257-
"description": ""
258-
},
259255
"experimental-sqlite": {
260256
"type": "boolean",
261257
"description": "experimental node:sqlite module"

‎doc/node.1‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -795,9 +795,6 @@ Use this flag to generate a blob that can be injected into the Node.js
795795
binary to produce a single executable application. See the documentation
796796
about this configuration for details.
797797
.
798-
.It Fl -experimental-shadow-realm
799-
Use this flag to enable ShadowRealm support.
800-
.
801798
.It Fl -experimental-storage-inspection
802799
Enable experimental support for storage inspection
803800
.
@@ -2006,8 +2003,6 @@ one is included in the list below.
20062003
.It
20072004
\fB--experimental-require-module\fR
20082005
.It
2009-
\fB--experimental-shadow-realm\fR
2010-
.It
20112006
\fB--experimental-specifier-resolution\fR
20122007
.It
20132008
\fB--experimental-stream-iter\fR

‎eslint.config.mjs‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,6 @@ export default [
145145
TextEncoderStream: 'readonly',
146146
TransformStream: 'readonly',
147147
TransformStreamDefaultController: 'readonly',
148-
ShadowRealm: 'readonly',
149148
SubtleCrypto: 'readonly',
150149
WritableStream: 'readonly',
151150
WritableStreamDefaultWriter: 'readonly',

‎lib/eslint.config_partial.mjs‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -240,12 +240,6 @@ export default [
240240
name: 'Response',
241241
message: "Use `const { Response } = require('internal/deps/undici/undici');` instead of the global.",
242242
},
243-
// ShadowRealm is not available in primordials because it can be
244-
// disabled with --no-harmony-shadow-realm CLI flag.
245-
{
246-
name: 'ShadowRealm',
247-
message: 'Use `const { ShadowRealm } = globalThis;` instead of the global.',
248-
},
249243
// SharedArrayBuffer is not available in primordials because it can be
250244
// disabled with --enable-sharedarraybuffer-per-context CLI flag.
251245
{

‎lib/internal/bootstrap/realm.js‎

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// This file is executed in every realm that is created by Node.js, including
2-
// the context of main thread, worker threads, and ShadowRealms.
2+
// the context of the main thread and worker threads.
33
// Only per-realm internal states and bindings should be bootstrapped in this
44
// file and no globals should be exposed to the user code.
55
//
@@ -50,7 +50,6 @@
5050

5151
const {
5252
ArrayFrom,
53-
ArrayPrototypeFilter,
5453
ArrayPrototypeIncludes,
5554
ArrayPrototypeMap,
5655
ArrayPrototypePush,
@@ -280,13 +279,6 @@ class BuiltinModule {
280279
}
281280
}
282281

283-
static setRealmAllowRequireByUsers(ids) {
284-
canBeRequiredByUsersList =
285-
new SafeSet(ArrayPrototypeFilter(ids, (id) => ArrayPrototypeIncludes(publicBuiltinIds, id)));
286-
canBeRequiredByUsersWithoutSchemeList =
287-
new SafeSet(ArrayPrototypeFilter(ids, (id) => !schemelessBlockList.has(id)));
288-
}
289-
290282
// To be called during pre-execution when --expose-internals is on.
291283
// Enables the user-land module loader to access internal modules.
292284
static exposeInternals() {

‎lib/internal/bootstrap/shadow_realm.js‎

Lines changed: 0 additions & 21 deletions
This file was deleted.

‎lib/internal/errors.js‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,9 @@ function isPermissionModelError(err) {
121121

122122
/**
123123
* Every realm has its own prepareStackTraceCallback. When `error.stack` is
124-
* accessed, if the error is created in a shadow realm, the shadow realm's
125-
* prepareStackTraceCallback is invoked. Otherwise, the principal realm's
126-
* prepareStackTraceCallback is invoked. Note that accessing `error.stack`
127-
* of error objects created in a VM Context will always invoke the
128-
* prepareStackTraceCallback of the principal realm.
124+
* accessed, the principal realm's prepareStackTraceCallback is invoked.
125+
* Note that accessing `error.stack` of error objects created in a VM Context
126+
* will always invoke the prepareStackTraceCallback of the principal realm.
129127
* @param {object} globalThis The global object of the realm that the error was
130128
* created in. When the error object is created in a VM Context, this is the
131129
* global object of that VM Context.

‎lib/internal/process/pre_execution.js‎

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -74,34 +74,6 @@ function prepareWorkerThreadExecution() {
7474
});
7575
}
7676

77-
function prepareShadowRealmExecution() {
78-
// Patch the process object with legacy properties and normalizations.
79-
// Do not expand argv1 as it is not available in ShadowRealm.
80-
patchProcessObject(false);
81-
setupDebugEnv();
82-
83-
// Disable custom loaders in ShadowRealm.
84-
initializeModuleLoaders({ shouldSpawnLoaderHookWorker: false, shouldPreloadModules: false });
85-
const {
86-
privateSymbols: {
87-
host_defined_option_symbol,
88-
},
89-
} = internalBinding('util');
90-
const {
91-
vm_dynamic_import_default_internal,
92-
} = internalBinding('symbols');
93-
94-
// For ShadowRealm.prototype.importValue(), the referrer name is
95-
// always null, so the native ImportModuleDynamically() callback would
96-
// always fallback to look up the host-defined option from the
97-
// global object using host_defined_option_symbol. Using
98-
// vm_dynamic_import_default_internal as the host-defined option
99-
// instructs the JS-land importModuleDynamicallyCallback() to
100-
// proxy the request to defaultImportModuleDynamically().
101-
globalThis[host_defined_option_symbol] =
102-
vm_dynamic_import_default_internal;
103-
}
104-
10577
function prepareExecution(options) {
10678
const { expandArgv1, initializeModules, isMainThread, shouldSpawnLoaderHookWorker, shouldPreloadModules } = options;
10779

@@ -242,7 +214,6 @@ function initializeModuleLoaders(options) {
242214
}
243215
// Do not enable preload modules if custom loaders are disabled.
244216
// For example, loader workers are responsible for doing this themselves.
245-
// And preload modules are not supported in ShadowRealm as well.
246217
if (shouldPreloadModules) {
247218
loadPreloadModules();
248219
}
@@ -826,7 +797,6 @@ module.exports = {
826797
initializeModuleLoaders,
827798
prepareMainThreadExecution,
828799
prepareWorkerThreadExecution,
829-
prepareShadowRealmExecution,
830800
prepareTestRunnerMainExecution,
831801
markBootstrapComplete,
832802
loadPreloadModules,

‎node.gyp‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,6 @@
159159
'src/node_sea.cc',
160160
'src/node_sea_bin.cc',
161161
'src/node_serdes.cc',
162-
'src/node_shadow_realm.cc',
163162
'src/node_snapshotable.cc',
164163
'src/node_sockaddr.cc',
165164
'src/node_stat_watcher.cc',
@@ -291,7 +290,6 @@
291290
'src/node_revert.h',
292291
'src/node_root_certs.h',
293292
'src/node_sea.h',
294-
'src/node_shadow_realm.h',
295293
'src/node_snapshotable.h',
296294
'src/node_snapshot_builder.h',
297295
'src/node_sockaddr.h',

0 commit comments

Comments
 (0)