Skip to content

worker: fix exit code for error thrown in uncaughtException handler

When an uncaughtException handler itself throws in a worker, the worker exits with an error code of 0 instead of 7 1, 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, where exit 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#L167

Fixes: https://github.com/nodejs/node/issues/37996

Merge request reports

Loading