New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: enable crashpad for ELECTRON_RUN_AS_NODE processes #36460
Conversation
fix: add PID testing method wip: plumb fd into child_process in node
patches/chromium/chore_fix_file_decriptor_extraction_for_node_processes.patch
Outdated
Show resolved
Hide resolved
+ options.env.CRASHDUMP_SIGNAL_FD = fd; | ||
+ // On Linux, pass the PID of the crashpad handler process to the child process | ||
+ // which is needed by the crashpad client running in the child process. | ||
+ // https://source.chromium.org/chromium/chromium/src/+/110.0.5415.0:components/crash/core/app/crashpad_linux.cc;l=199-206 | ||
+ ArrayPrototypePush(args, `--crashpad-handler-pid=${process.getCrashpadHandlerPID()}`); | ||
+ options.env.CRASHPAD_HANDLER_PID = pid; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if options / options.env can be null, do we need to make sure we initialize those as objects here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I think that's a good callout, I'll add that in 🙇♀️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed in ecd98e8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a heads up, I reverted initializing options.env here in d0e268c after seeing multiple node test failures. It looks like node expects the options object to not be extendable here, so we can't create an options.env at this point if it doesn't already exist. We can add properties to options.env if it exists though, which our check should gate for.
@@ -27,13 +27,14 @@ index 73c1dc769542865bdf7a2a03c16cef141d3f4b05..35a096dcff6f7072391bccd7952da7e8 | |||
args = [...execArgv, modulePath, ...args]; | |||
|
|||
if (typeof options.stdio === 'string') { | |||
@@ -613,6 +613,21 @@ function normalizeSpawnArguments(file, args, options) { | |||
@@ -613,6 +613,22 @@ function normalizeSpawnArguments(file, args, options) { | |||
'options.windowsVerbatimArguments'); | |||
} | |||
|
|||
+ if (process.platform === 'linux') { | |||
+ if (ObjectPrototypeHasOwnProperty(options.env || {}, 'ELECTRON_RUN_AS_NODE') && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since options.env isn't necessarily set here, how does this work...? should this be options.env || process.env
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question, I think so? Made the change in 9463804
b449baf
to
bfb32aa
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test needs a little work!
bfb32aa
to
9463804
Compare
9d3bedb
to
d0e268c
Compare
} | ||
|
||
+ if (process.platform === 'linux') { | ||
+ if (ObjectPrototypeHasOwnProperty(options.env || process.env, 'ELECTRON_RUN_AS_NODE') && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not blocking on it, but what's the path forward for this patch? Is it something we're anticipating floating for the long-term?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there’s two approaches we could take in the long-term:
- Move this functionality out of our forked child_process.fork and into the new UtilityProcess API. If we did that, we could likely remove this patch, but I think the API needs additional feature work before that can be done.
- This becomes a long-running patch similar to our implementation of Breakpad in Node (see b10f243 )
I think the immediate plan is #2, but we’re looking at if #1 is feasible
Release Notes Persisted
|
I was unable to backport this PR to "22-x-y" cleanly; |
@VerteDinde has manually backported this PR to "22-x-y", please check out #36483 |
* wip: enable crashpad for node processes fix: add PID testing method wip: plumb fd into child_process in node * node::ProcessInitializationFlags::kNoDefaultSignalHandling * chore: clean up debug logging * chore: gate platform includes * test: clean up node process test * fix: pass pid in node_main * chore: cleanup impl * chore: fixup patch method definition * fix: expose bound methods to node_main * fix: remove bound methods * fix: crashpad connection for all ELECTRON_RUN_AS_NODE processes * chore: fix typo * chore: address review feedback * chore: delay crashpad initialization * chore: ensure options.env, code hygiene * chore: add argv test, check for process.env over {} * fix: fix test, return options.env immutability Co-authored-by: VerteDinde <keeleymhammond@gmail.com> Co-authored-by: Jeremy Rose <jeremya@chromium.org> Co-authored-by: VerteDinde <vertedinde@electronjs.org>
Description of Change
Fixes #36030
Co-authored by: @VerteDinde , @nornagon
Release Notes
Notes: Enable crashpad for ELECTRON_RUN_AS_NODE processes.