unhandledRejection
The Node.js process event emitted when a promise is rejected and no handler catches it.
In more detail
Since Node.js 15 an unhandled rejection is treated like an uncaught exception and ends the process. Attach .catch() or use try...catch around await so every rejection is handled.
Related terms
- Promise — A JavaScript object that stands for a result that is not ready yet and will later either succeed with a value or fail with an error.
- uncaughtException — The Node.js process event emitted when an error is thrown and nothing catches it; by default the process prints the stack trace and exits with code 1.
- try...catch — A statement that runs code in a try block and, if that code throws an exception, runs a catch block instead of crashing.
Taught in
- Global Error Trapping: uncaughtException & Exits — Node.js Internals & Backend Services