#53527: refactor: hand crashpad env to run-as-node children from lib/node/init
Merged
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'sChildProcess.prototype.spawnandspawnSync, the two functions every async (spawn/execFile/exec/fork) and sync (spawnSync/execFileSync/execSync) path reaches with the already-normalizedfileandenvPairs, so the condition is the same as before:file === process.execPathandELECTRON_RUN_AS_NODEin the child env. - Verified with a probe app reading
/proc/self/environin the child:fork,spawn,spawnSyncandexecFileSyncofprocess.execPathwithELECTRON_RUN_AS_NODEreceiveCRASHDUMP_SIGNAL_FD/CRASHPAD_HANDLER_PIDoncecrashReporter.start()has run and not before; other children never do. ThecrashReporterspecs for node-process and nested node-process minidumps and "linux child process args are not modified" pass.
Checklist
- I have built and tested this change
- I have filled out the PR description
- I have reviewed and verified the changes
-
npm testpasses
Release Notes
Notes: none
Backports
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