-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
worker: fix exit code for error thrown in uncaughtException handler #38012
worker: fix exit code for error thrown in uncaughtException handler #38012
Conversation
Change worker exit code when the unhandled exception handler throws from 0 to 7 fixes: nodejs#37996
ddcff99
to
7cf8425
Compare
This comment has been minimized.
This comment has been minimized.
Thanks for fixing this so quickly. I think the docs need an update as well if we're going with 7 and not 1
https://nodejs.org/api/worker_threads.html#worker_threads_event_exit |
I've changed the exit code to |
This comment has been minimized.
This comment has been minimized.
287f22e
to
7779d71
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@nodejs/workers |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Change worker exit code when the unhandled exception handler throws from 0 to 7 fixes: #37996 PR-URL: #38012 Fixes: #37996 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: James M Snell <[email protected]>
Landed in 6986fa0 |
thanks!
The 7 slipped in there again "from 0 to 7" |
Yeah, it looks like I missed amending the commit message. The PR is good though, and correctly exits with |
Change worker exit code when the unhandled exception handler throws from 0 to 7 fixes: #37996 PR-URL: #38012 Fixes: #37996 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: James M Snell <[email protected]>
When an
uncaughtException
handler itself throws in a worker, the worker exits with an error code of 0 instead of71, which happens because the worker thread global handler catches the error, and exitCode stays 0.My fix only emits
exit
for "regular" unhandled exceptions (which shouldn't actually reach that code anyway, as it should set_exiting
correctly in the "inner" handler) to emulate the same behaviour that happens in non-workers, whereexit
is not emitted when an error is thrown from a handler.The
process._exiting
logic was essentially taken from here: https://github.com/nodejs/node/blob/master/lib/internal/process/execution.js#L167Fixes: #37996