codebytere

#53547: refactor: register Electron's js2c bundles as internal Node builtins

Merged
Created: Sep 4, 2026, 2:59:03 PM
Merged: Sep 6, 2026, 12:15:19 PM
2 comments
Target: main

Description of Change

Electron's framework bundles were registered with Node as electron/js2c/<name>. Node treats every builtin id that does not start with internal/ as public, so they showed up in require('module').builtinModules, and require('node:electron/js2c/browser_init') / process.getBuiltinModule('electron/js2c/browser_init') would load and run the browser init bundle in whatever process asked, which under ELECTRON_RUN_AS_NODE dereferences a null ElectronBrowserClient and crashes. That was only ever "needed" because Node's runMain had to be able to load the bundle by id; with #53537 running the bundles from the embedder callback nothing requires them to be public.

The bundles are now emitted under gen/internal/electron/js2c/, so js2c registers them as internal/electron/js2c/<name>: they disappear from builtinModules, require/getBuiltinModule return ERR_UNKNOWN_BUILTIN_MODULE/undefined for them like any other internal id, and parallel/test-process-get-builtin (which iterates builtinModules) passes and comes off the disabled list. The visible side effect is that stack frames inside Electron's bundles read node:internal/electron/js2c/browser_init instead of node:electron/js2c/browser_init.

Checklist

Release Notes

Notes: Electron's internal JavaScript bundles are no longer listed in require('module').builtinModules or loadable through process.getBuiltinModule().

Backports

45-x-y
Merged
PR Number
#53624
Merged At
Sep 6, 2026, 1:28:27 PM
Released In
Not yet
Release Date
Not yet

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