codebytere

#53528: refactor: look up internalBinding and linked bindings without patching Node

Merged
Created: Sep 4, 2026, 9:04:19 AM
Merged: Sep 5, 2026, 4:00:16 AM
2 comments
Target: main

Description of Change

Two Node patches existed only to hand Electron things it can reach on its own:

  • refactor_allow_embedder_overriding_of_internal_fs_calls stashed internalBinding on process during bootstrap so lib/node/asar-fs-wrapper.ts could grab (and delete) it. The wrapper runs as a builtin with Node's internal require, and require('internal/bootstrap/realm') already returns the loader exports including internalBinding, so it takes it from there and process.internalBinding never exists.
  • expose_get_builtin_module_function exported node::binding::get_linked_module() so sandboxed preloads (no node::Environment) could find a linked binding by name in shell/renderer/preload_utils.cc. Electron's own NODE_LINKED_BINDING_CONTEXT_AWARE macro now also emits a get_linked_module_<name>() accessor next to each binding, and NodeBindings::GetLinkedBinding() resolves a name against the same per-process binding lists RegisterBuiltinBindings() uses; preload_utils.cc calls that instead. This also retires the TODO(codebytere) in the patch.

Verified on Linux: asar reads/stat in the browser, renderer and ELECTRON_RUN_AS_NODE, process.internalBinding absent everywhere, a sandboxed preload using ipcRenderer, and the asar, ipcRenderer and process spec files pass.

Checklist

Release Notes

Notes: none

Backports

45-x-y
In-flight
PR Number
#53580
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