-
-
Notifications
You must be signed in to change notification settings - Fork 33.8k
worker: fix exit code for error thrown in uncaughtException handler #38012
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
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.
|
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 |
When an
uncaughtExceptionhandler 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
exitfor "regular" unhandled exceptions (which shouldn't actually reach that code anyway, as it should set_exitingcorrectly in the "inner" handler) to emulate the same behaviour that happens in non-workers, whereexitis not emitted when an error is thrown from a handler.The
process._exitinglogic was essentially taken from here: https://github.com/nodejs/node/blob/master/lib/internal/process/execution.js#L167Fixes: #37996