Skip to content

Commit 02cca56

Browse files
authored
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> PR-URL: #65650 Reviewed-By: Chengzhong Wu <legendecas@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
1 parent f6bb3e7 commit 02cca56

55 files changed

Lines changed: 25 additions & 801 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
@@ -1604,16 +1604,6 @@ Use this flag to generate a blob that can be injected into the Node.js
16041604
binary to produce a [single executable application][]. See the documentation
16051605
about [this configuration][`--experimental-sea-config`] for details.
16061606

1607-
### `--experimental-shadow-realm`
1608-
1609-
<!-- YAML
1610-
added:
1611-
- v19.0.0
1612-
- v18.13.0
1613-
-->
1614-
1615-
Use this flag to enable [ShadowRealm][] support.
1616-
16171607
### `--experimental-storage-inspection`
16181608

16191609
<!-- YAML
@@ -4412,7 +4402,6 @@ one is included in the list below.
44124402
* `--experimental-quic`
44134403
* `--experimental-repl-await`
44144404
* `--experimental-require-module`
4415-
* `--experimental-shadow-realm`
44164405
* `--experimental-specifier-resolution`
44174406
* `--experimental-stream-iter`
44184407
* `--experimental-strip-private-modules`
@@ -4921,8 +4910,6 @@ documented here:
49214910

49224911
### `--expose-gc`
49234912

4924-
### `--harmony-shadow-realm`
4925-
49264913
### `--heap-snapshot-on-oom`
49274914

49284915
### `--interpreted-frames-native-stack`
@@ -5029,7 +5016,6 @@ node --stack-trace-limit=12 -p -e "Error.stackTraceLimit" # prints 12
50295016
[Permission Model]: permissions.md#permission-model
50305017
[REPL]: repl.md
50315018
[ScriptCoverage]: https://chromedevtools.github.io/devtools-protocol/tot/Profiler#type-ScriptCoverage
5032-
[ShadowRealm]: https://github.com/tc39/proposal-shadowrealm
50335019
[Source Map]: https://tc39.es/ecma426/
50345020
[Test tags]: test.md#test-tags
50355021
[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
@@ -379,10 +379,6 @@
379379
"type": "boolean",
380380
"description": "Legacy alias for --require-module"
381381
},
382-
"experimental-shadow-realm": {
383-
"type": "boolean",
384-
"description": ""
385-
},
386382
"experimental-sqlite": {
387383
"type": "boolean",
388384
"description": "experimental node:sqlite module"

‎doc/node.1‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -909,9 +909,6 @@ Use this flag to generate a blob that can be injected into the Node.js
909909
binary to produce a single executable application. See the documentation
910910
about this configuration for details.
911911
.
912-
.It Fl -experimental-shadow-realm
913-
Use this flag to enable ShadowRealm support.
914-
.
915912
.It Fl -experimental-storage-inspection
916913
Enable experimental support for storage inspection
917914
.
@@ -2358,8 +2355,6 @@ one is included in the list below.
23582355
.It
23592356
\fB--experimental-require-module\fR
23602357
.It
2361-
\fB--experimental-shadow-realm\fR
2362-
.It
23632358
\fB--experimental-specifier-resolution\fR
23642359
.It
23652360
\fB--experimental-stream-iter\fR

‎eslint.config.mjs‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,6 @@ export default [
144144
ReadableStreamDefaultReader: 'readonly',
145145
Response: 'readonly',
146146
sessionStorage: 'readonly',
147-
ShadowRealm: 'readonly',
148147
Storage: 'readonly',
149148
SubtleCrypto: 'readonly',
150149
TextDecoderStream: 'readonly',

‎lib/eslint.config_partial.mjs‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -250,12 +250,6 @@ export default [
250250
name: 'Response',
251251
message: "Use `const { Response } = require('internal/deps/undici/undici');` instead of the global.",
252252
},
253-
// ShadowRealm is not available in primordials because it can be
254-
// disabled with --no-harmony-shadow-realm CLI flag.
255-
{
256-
name: 'ShadowRealm',
257-
message: 'Use `const { ShadowRealm } = globalThis;` instead of the global.',
258-
},
259253
// SharedArrayBuffer is not available in primordials because it can be
260254
// disabled with --enable-sharedarraybuffer-per-context CLI flag.
261255
{

‎lib/internal/bootstrap/realm.js‎

Lines changed: 3 additions & 10 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
//
@@ -233,8 +233,8 @@ const internalBuiltinIds = builtinIds
233233
.filter((id) => StringPrototypeStartsWith(id, 'internal/') && id !== selfId);
234234

235235
// When --expose-internals is on we'll add the internal builtin ids to these.
236-
let canBeRequiredByUsersList = new SafeSet(publicBuiltinIds);
237-
let canBeRequiredByUsersWithoutSchemeList =
236+
const canBeRequiredByUsersList = new SafeSet(publicBuiltinIds);
237+
const canBeRequiredByUsersWithoutSchemeList =
238238
new SafeSet(publicBuiltinIds.filter((id) => !schemelessBlockList.has(id)));
239239

240240
/**
@@ -302,13 +302,6 @@ class BuiltinModule {
302302
(policy) => ArrayPrototypeSlice(policy));
303303
}
304304

305-
static setRealmAllowRequireByUsers(ids) {
306-
canBeRequiredByUsersList =
307-
new SafeSet(ArrayPrototypeFilter(ids, (id) => ArrayPrototypeIncludes(publicBuiltinIds, id)));
308-
canBeRequiredByUsersWithoutSchemeList =
309-
new SafeSet(ArrayPrototypeFilter(ids, (id) => !schemelessBlockList.has(id)));
310-
}
311-
312305
// To be called during pre-execution when --expose-internals is on.
313306
// Enables the user-land module loader to access internal modules.
314307
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
@@ -187,11 +187,9 @@ function isPermissionModelError(err) {
187187

188188
/**
189189
* Every realm has its own prepareStackTraceCallback. When `error.stack` is
190-
* accessed, if the error is created in a shadow realm, the shadow realm's
191-
* prepareStackTraceCallback is invoked. Otherwise, the principal realm's
192-
* prepareStackTraceCallback is invoked. Note that accessing `error.stack`
193-
* of error objects created in a VM Context will always invoke the
194-
* prepareStackTraceCallback of the principal realm.
190+
* accessed, the principal realm's prepareStackTraceCallback is invoked.
191+
* Note that accessing `error.stack` of error objects created in a VM Context
192+
* will always invoke the prepareStackTraceCallback of the principal realm.
195193
* @param {object} globalThis The global object of the realm that the error was
196194
* created in. When the error object is created in a VM Context, this is the
197195
* 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
@@ -78,34 +78,6 @@ function prepareWorkerThreadExecution() {
7878
});
7979
}
8080

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

@@ -339,7 +311,6 @@ function initializeModuleLoaders(options) {
339311
if (getEmbedderOptions().hasEmbedderPreload) {
340312
runEmbedderPreload();
341313
}
342-
// Preload modules are not supported in ShadowRealm.
343314
if (shouldPreloadModules) {
344315
loadPreloadModules();
345316
}
@@ -880,7 +851,6 @@ module.exports = {
880851
initializeModuleLoaders,
881852
prepareMainThreadExecution,
882853
prepareWorkerThreadExecution,
883-
prepareShadowRealmExecution,
884854
prepareTestRunnerMainExecution,
885855
markBootstrapComplete,
886856
loadPreloadModules,

‎node.gyp‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,6 @@
167167
'src/node_sea.cc',
168168
'src/node_sea_bin.cc',
169169
'src/node_serdes.cc',
170-
'src/node_shadow_realm.cc',
171170
'src/node_snapshotable.cc',
172171
'src/node_sockaddr.cc',
173172
'src/node_stat_watcher.cc',
@@ -305,7 +304,6 @@
305304
'src/node_revert.h',
306305
'src/node_root_certs.h',
307306
'src/node_sea.h',
308-
'src/node_shadow_realm.h',
309307
'src/node_snapshotable.h',
310308
'src/node_snapshot_builder.h',
311309
'src/node_sockaddr.h',

0 commit comments

Comments
 (0)