Skip to content

Commit eff3e1a

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 3cd2d6e commit eff3e1a

53 files changed

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

1574-
### `--experimental-shadow-realm`
1575-
1576-
<!-- YAML
1577-
added:
1578-
- v19.0.0
1579-
- v18.13.0
1580-
-->
1581-
1582-
Use this flag to enable [ShadowRealm][] support.
1583-
15841574
### `--experimental-storage-inspection`
15851575

15861576
<!-- YAML
@@ -4175,7 +4165,6 @@ one is included in the list below.
41754165
* `--experimental-quic`
41764166
* `--experimental-repl-await`
41774167
* `--experimental-require-module`
4178-
* `--experimental-shadow-realm`
41794168
* `--experimental-specifier-resolution`
41804169
* `--experimental-stream-iter`
41814170
* `--experimental-test-isolation`
@@ -4682,8 +4671,6 @@ documented here:
46824671

46834672
### `--expose-gc`
46844673

4685-
### `--harmony-shadow-realm`
4686-
46874674
### `--heap-snapshot-on-oom`
46884675

46894676
### `--interpreted-frames-native-stack`
@@ -4789,7 +4776,6 @@ node --stack-trace-limit=12 -p -e "Error.stackTraceLimit" # prints 12
47894776
[Permission Model]: permissions.md#permission-model
47904777
[REPL]: repl.md
47914778
[ScriptCoverage]: https://chromedevtools.github.io/devtools-protocol/tot/Profiler#type-ScriptCoverage
4792-
[ShadowRealm]: https://github.com/tc39/proposal-shadowrealm
47934779
[Source Map]: https://tc39.es/ecma426/
47944780
[Test tags]: test.md#test-tags
47954781
[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
@@ -359,10 +359,6 @@
359359
"type": "boolean",
360360
"description": "Legacy alias for --require-module"
361361
},
362-
"experimental-shadow-realm": {
363-
"type": "boolean",
364-
"description": ""
365-
},
366362
"experimental-sqlite": {
367363
"type": "boolean",
368364
"description": "experimental node:sqlite module"

‎doc/node.1‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -864,9 +864,6 @@ Use this flag to generate a blob that can be injected into the Node.js
864864
binary to produce a single executable application. See the documentation
865865
about this configuration for details.
866866
.
867-
.It Fl -experimental-shadow-realm
868-
Use this flag to enable ShadowRealm support.
869-
.
870867
.It Fl -experimental-storage-inspection
871868
Enable experimental support for storage inspection
872869
.
@@ -2182,8 +2179,6 @@ one is included in the list below.
21822179
.It
21832180
\fB--experimental-require-module\fR
21842181
.It
2185-
\fB--experimental-shadow-realm\fR
2186-
.It
21872182
\fB--experimental-specifier-resolution\fR
21882183
.It
21892184
\fB--experimental-stream-iter\fR

‎eslint.config.mjs‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,6 @@ export default [
143143
ReadableStreamDefaultReader: 'readonly',
144144
Response: 'readonly',
145145
sessionStorage: 'readonly',
146-
ShadowRealm: 'readonly',
147146
Storage: 'readonly',
148147
SubtleCrypto: 'readonly',
149148
TextDecoderStream: '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: 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
//
@@ -230,8 +230,8 @@ const internalBuiltinIds = builtinIds
230230
.filter((id) => StringPrototypeStartsWith(id, 'internal/') && id !== selfId);
231231

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

237237
/**
@@ -284,13 +284,6 @@ class BuiltinModule {
284284
}
285285
}
286286

287-
static setRealmAllowRequireByUsers(ids) {
288-
canBeRequiredByUsersList =
289-
new SafeSet(ArrayPrototypeFilter(ids, (id) => ArrayPrototypeIncludes(publicBuiltinIds, id)));
290-
canBeRequiredByUsersWithoutSchemeList =
291-
new SafeSet(ArrayPrototypeFilter(ids, (id) => !schemelessBlockList.has(id)));
292-
}
293-
294287
// To be called during pre-execution when --expose-internals is on.
295288
// Enables the user-land module loader to access internal modules.
296289
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
@@ -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-
// Disable custom loaders in ShadowRealm.
88-
initializeModuleLoaders({ shouldSpawnLoaderHookWorker: false, 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, shouldSpawnLoaderHookWorker, shouldPreloadModules } = options;
11183

@@ -355,7 +327,6 @@ function initializeModuleLoaders(options) {
355327
}
356328
// Do not enable preload modules if custom loaders are disabled.
357329
// For example, loader workers are responsible for doing this themselves.
358-
// And preload modules are not supported in ShadowRealm as well.
359330
if (shouldPreloadModules) {
360331
loadPreloadModules();
361332
}
@@ -959,7 +930,6 @@ module.exports = {
959930
initializeModuleLoaders,
960931
prepareMainThreadExecution,
961932
prepareWorkerThreadExecution,
962-
prepareShadowRealmExecution,
963933
prepareTestRunnerMainExecution,
964934
markBootstrapComplete,
965935
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',
@@ -304,7 +303,6 @@
304303
'src/node_revert.h',
305304
'src/node_root_certs.h',
306305
'src/node_sea.h',
307-
'src/node_shadow_realm.h',
308306
'src/node_snapshotable.h',
309307
'src/node_snapshot_builder.h',
310308
'src/node_sockaddr.h',

0 commit comments

Comments
 (0)