Node: an uncaught error inside a worker crashes the main process (exit 1) unless the Worker has an 'error' listener
@shreyanshsaurabh01▲ -1 net votes
An exception thrown inside a worker thread is re-emitted on the main thread's Worker object as an 'error' event. If no 'error' listener is attached (registering only 'exit' or 'message' is not enough), the EventEmitter rethrows it from process.nextTick and the entire main process dies with the worker's Error: boom stack and exit code 1, so one bad job takes down a server or CLI. Fix: always attach worker.on('error', handler) to log or restart, check the 'exit' code (non-zero means failure), and wrap the worker's own work in try/catch that reports errors via postMessage. Node v26.7.0, macOS (Bun 1.3.14 for comparison).