-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
child_process: use signal.reason in child process abort #47817
child_process: use signal.reason in child process abort #47817
Conversation
Shouldn't we keep rejecting with an |
Oh ok my bad it seems Thanks! |
Ok so the original issue mentions wanting the behavior to be like fetch, fetch seems to just pass the error without wrapping on AbortError so which way would be correct 🧐 |
We don't want to throw |
Done updated to use cause, and included tests where the passed value is not a error, PTAL :-) Thanks! |
Commit Queue failed- Loading data for nodejs/node/pull/47817 ✔ Done loading data for nodejs/node/pull/47817 ----------------------------------- PR info ------------------------------------ Title child_process: use signal.reason in child process abort (#47817) Author Debadree Chatterjee (@debadree25) Branch debadree25:ft/child-process-abort -> nodejs:main Labels child_process, semver-major, author ready, needs-ci, commit-queue-squash Commits 3 - child_process: use signal.reason in child process abort - fixup! add another test - fixup! use cause Committers 1 - Debadree Chatterjee PR-URL: https://github.com/nodejs/node/pull/47817 Fixes: https://github.com/nodejs/node/issues/47814 Reviewed-By: Benjamin Gruenbaum Reviewed-By: Antoine du Hamel ------------------------------ Generated metadata ------------------------------ PR-URL: https://github.com/nodejs/node/pull/47817 Fixes: https://github.com/nodejs/node/issues/47814 Reviewed-By: Benjamin Gruenbaum Reviewed-By: Antoine du Hamel -------------------------------------------------------------------------------- ℹ This PR was created on Tue, 02 May 2023 11:22:01 GMT ✔ Approvals: 2 ✔ - Benjamin Gruenbaum (@benjamingr): https://github.com/nodejs/node/pull/47817#pullrequestreview-1409488231 ✔ - Antoine du Hamel (@aduh95) (TSC): https://github.com/nodejs/node/pull/47817#pullrequestreview-1415776719 ✘ semver-major requires at least 2 TSC approvals ✔ Last GitHub CI successful ℹ Last Full PR CI on 2023-05-04T04:48:59Z: https://ci.nodejs.org/job/node-test-pull-request/51618/ - Querying data for job/node-test-pull-request/51618/ ✔ Last Jenkins CI successful -------------------------------------------------------------------------------- ✔ Aborted `git node land` session in /home/runner/work/node/node/.ncuhttps://github.com/nodejs/node/actions/runs/4902048348 |
Ah requires another TSC approval could someone from @nodejs/tsc take a look! Thanks! |
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.
LGTM
test/parallel/test-child-process-exec-abortcontroller-promisified.js
Outdated
Show resolved
Hide resolved
As this just adds .reason as .cause and doesn't replace the AbortError this also doesn't need to land as semver-major as it doesn't change error codes but rather just adds another property on the exception |
@@ -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 comment
The 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 comment
The 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 comment
The 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 comment
The 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
Oh ok so removing the semver-major then @benjamingr |
Co-authored-by: Darshan Sen <raisinten@gmail.com>
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.
still lgtm
Landed in 2dc4290 |
Fixes: nodejs#47814 PR-URL: nodejs#47817 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Darshan Sen <raisinten@gmail.com>
Fixes: #47814