Unhandled Exception Management

suggest change

An uncaught exception indicates that the application reached an unexpected state. Handle expected operational errors where they occur. Reserve the process-level hook for unexpected failures.

Do not swallow an exception and continue normal work:

process.on('uncaughtException', error => {
    console.error(error);
});

The handler may synchronously log the error before shutdown. Use a service manager or container orchestrator to restart the terminated process:

process.on('uncaughtException', error => {
    console.error(error);
    process.exit(1);
});

The process may be in an undefined state after an uncaught exception, so the handler should perform only essential synchronous cleanup before exiting.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents