codebytere

#53546: fix: only run the node_init preload in the principal realm

Merged
Created: Sep 4, 2026, 2:54:00 PM
Merged: Sep 5, 2026, 4:00:00 AM
3 comments
Target: main

Description of Change

Node runs the embedder preload for every realm it bootstraps, including ShadowRealms, and Electron's preload is the node_init bundle (asar support, child_process hooks). Inside a ShadowRealm that bundle has nothing to work with and currently dies on its first line, so every new ShadowRealm() in a process with Node integration prints CompileAndCall failed to evaluate electron script (electron/js2c/node_init): Uncaught TypeError: internalBinding is not a function to stderr. OnNodePreload now returns early for any realm other than the principal one.

That stderr line was the only reason parallel/test-shadow-realm-custom-loaders was disabled, so it comes off the list; all eight test-shadow-realm* tests pass. #53528 carries the same guard because its asar change needs it; whichever lands second just loses the hunk.

Checklist

Release Notes

Notes: Fixed a spurious node_init error being logged when creating a ShadowRealm with Node.js integration enabled.

Backports

44-x-y
In-flight
PR Number
#53579
Waiting to be merged
45-x-y
In-flight
PR Number
#53578
Waiting to be merged

Semver Impact

Major
Breaking changes
Minor
New features
Patch
Bug fixes
None
Docs, tests, etc.

Semantic Versioning helps users understand the impact of updates:

  • Major (X.y.z): Breaking changes that may require code modifications
  • Minor (x.Y.z): New features that maintain backward compatibility
  • Patch (x.y.Z): Bug fixes that don't change the API
  • None: Changes that don't affect using facing parts of Electron