Skip to content

Commit 52ba7ce

Browse files
anonrigcursoragent
authored andcommitted
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 045ff95 commit 52ba7ce

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
@@ -1419,16 +1419,6 @@ Use this flag to generate a blob that can be injected into the Node.js
14191419
binary to produce a [single executable application][]. See the documentation
14201420
about [this configuration][`--experimental-sea-config`] for details.
14211421

1422-
### `--experimental-shadow-realm`
1423-
1424-
<!-- YAML
1425-
added:
1426-
- v19.0.0
1427-
- v18.13.0
1428-
-->
1429-
1430-
Use this flag to enable [ShadowRealm][] support.
1431-
14321422
### `--experimental-storage-inspection`
14331423

14341424
<!-- YAML
@@ -3914,7 +3904,6 @@ one is included in the list below.
39143904
* `--experimental-quic`
39153905
* `--experimental-repl-await`
39163906
* `--experimental-require-module`
3917-
* `--experimental-shadow-realm`
39183907
* `--experimental-specifier-resolution`
39193908
* `--experimental-stream-iter`
39203909
* `--experimental-test-isolation`
@@ -4419,8 +4408,6 @@ documented here:
44194408

44204409
### `--expose-gc`
44214410

4422-
### `--harmony-shadow-realm`
4423-
44244411
### `--heap-snapshot-on-oom`
44254412

44264413
### `--interpreted-frames-native-stack`
@@ -4526,7 +4513,6 @@ node --stack-trace-limit=12 -p -e "Error.stackTraceLimit" # prints 12
45264513
[Permission Model]: permissions.md#permission-model
45274514
[REPL]: repl.md
45284515
[ScriptCoverage]: https://chromedevtools.github.io/devtools-protocol/tot/Profiler#type-ScriptCoverage
4529-
[ShadowRealm]: https://github.com/tc39/proposal-shadowrealm
45304516
[Source Map]: https://tc39.es/ecma426/
45314517
[Test tags]: test.md#test-tags
45324518
[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
@@ -791,9 +791,6 @@ Use this flag to generate a blob that can be injected into the Node.js
791791
binary to produce a single executable application. See the documentation
792792
about this configuration for details.
793793
.
794-
.It Fl -experimental-shadow-realm
795-
Use this flag to enable ShadowRealm support.
796-
.
797794
.It Fl -experimental-storage-inspection
798795
Enable experimental support for storage inspection
799796
.
@@ -2016,8 +2013,6 @@ one is included in the list below.
20162013
.It
20172014
\fB--experimental-require-module\fR
20182015
.It
2019-
\fB--experimental-shadow-realm\fR
2020-
.It
20212016
\fB--experimental-specifier-resolution\fR
20222017
.It
20232018
\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
//
@@ -226,8 +226,8 @@ const internalBuiltinIds = builtinIds
226226
.filter((id) => StringPrototypeStartsWith(id, 'internal/') && id !== selfId);
227227

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

233233
/**
@@ -280,13 +280,6 @@ class BuiltinModule {
280280
}
281281
}
282282

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-
290283
// To be called during pre-execution when --expose-internals is on.
291284
// Enables the user-land module loader to access internal modules.
292285
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

@@ -247,7 +219,6 @@ function initializeModuleLoaders(options) {
247219
}
248220
// Do not enable preload modules if custom loaders are disabled.
249221
// For example, loader workers are responsible for doing this themselves.
250-
// And preload modules are not supported in ShadowRealm as well.
251222
if (shouldPreloadModules) {
252223
loadPreloadModules();
253224
}
@@ -830,7 +801,6 @@ module.exports = {
830801
initializeModuleLoaders,
831802
prepareMainThreadExecution,
832803
prepareWorkerThreadExecution,
833-
prepareShadowRealmExecution,
834804
prepareTestRunnerMainExecution,
835805
markBootstrapComplete,
836806
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',
@@ -289,7 +288,6 @@
289288
'src/node_revert.h',
290289
'src/node_root_certs.h',
291290
'src/node_sea.h',
292-
'src/node_shadow_realm.h',
293291
'src/node_snapshotable.h',
294292
'src/node_snapshot_builder.h',
295293
'src/node_sockaddr.h',

0 commit comments

Comments
 (0)