-
-
Notifications
You must be signed in to change notification settings - Fork 31.7k
child_process: use signal.reason in child process abort #47817
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
Changes from all commits
f2e3974
29954c9
6fc91a2
e26e572
ece8b5e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -712,12 +712,12 @@ function normalizeSpawnArguments(file, args, options) { | |
}; | ||
} | ||
|
||
function abortChildProcess(child, killSignal) { | ||
function abortChildProcess(child, killSignal, reason) { | ||
if (!child) | ||
return; | ||
try { | ||
if (child.kill(killSignal)) { | ||
child.emit('error', new AbortError()); | ||
child.emit('error', new AbortError(undefined, { cause: reason })); | ||
} | ||
} catch (err) { | ||
child.emit('error', err); | ||
|
@@ -787,7 +787,7 @@ function spawn(file, args, options) { | |
} | ||
|
||
function onAbortListener() { | ||
abortChildProcess(child, killSignal); | ||
abortChildProcess(child, killSignal, options.signal.reason); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: accessing options.signal.reason can potentially throw though I don't think we guard against that anywhere else to be honest. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah I see, why does it throw tho? I have never seen it like that, is there any way to guard? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It could be a getter that throws. To guard it against that, we would need a try/catch: let reason;
try { ({ reason } = options.signal); } catch {}
abortChildProcess(child, killSignal, reason); If we don’t guard against that anywhere else, it’s probably OK to ignore for this PR, but we should do it in a follow up PR IMHO. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm i check no where else it guarded maybe we could do a larger refactor in a followup |
||
} | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.