codebytere

#53527: refactor: hand crashpad env to run-as-node children from lib/node/init

Merged
Created: Sep 4, 2026, 8:56:17 AM
Merged: Sep 5, 2026, 4:00:32 AM
3 comments
Target: main

Description of Change

On Linux, ELECTRON_RUN_AS_NODE children need crashpad's handler PID and signal fd in their environment so shell/app/node_main.cc can connect them to the parent's crash handler. That was done by patching Node's child_process.normalizeSpawnArguments(); this moves it into lib/node/init.ts, next to the existing child_process.fork hook, and drops the patch.

  • The hook wraps internal/child_process's ChildProcess.prototype.spawn and spawnSync, the two functions every async (spawn/execFile/exec/fork) and sync (spawnSync/execFileSync/execSync) path reaches with the already-normalized file and envPairs, so the condition is the same as before: file === process.execPath and ELECTRON_RUN_AS_NODE in the child env.
  • Verified with a probe app reading /proc/self/environ in the child: fork, spawn, spawnSync and execFileSync of process.execPath with ELECTRON_RUN_AS_NODE receive CRASHDUMP_SIGNAL_FD/CRASHPAD_HANDLER_PID once crashReporter.start() has run and not before; other children never do. The crashReporter specs for node-process and nested node-process minidumps and "linux child process args are not modified" pass.

Checklist

Release Notes

Notes: none

Backports

44-x-y
In-flight
PR Number
#53581
Waiting to be merged
45-x-y
In-flight
PR Number
#53582
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