Promise.reject(new Error("x"));
setTimeout(() => console.log("still alive"), 100);
The process prints the error and exits with code 1 before the timer fires
The process prints the error and exits with code 1 before the timer fires.
Since Node 15, the default --unhandled-rejections mode is throw. In this mode, Node raises an unhandled rejection as an uncaught exception. The uncaught exception crashes the process with exit code 1.
"It logs still alive, after a deprecation warning about the rejection" is wrong for Node 22. Printing a warning and continuing was the behavior in Node 14 and earlier.
Read more