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.

Carrying on after an uncaught exception runs with half-updated state, which can corrupt data or leak resources.

In more detail

A listener can log the error, but the program is then in an unknown state, so the only safe next step is to exit. A process supervisor should then restart it in a clean state.

Related terms

Taught in

References