The uncaughtException event is a Node.js process event emitted when an exception reaches the event loop without being caught.
Node.js emits the uncaughtException event when an exception escapes every try/catch handler. Handling it overrides the default process-abort behavior, so the handler must choose whether to continue or terminate. section 11.2.2
Two practical strategies are available:
Resume operation: print the error to standard error and let the process continue, while accepting that the failure may have left it in a bad state. section 11.2.2
Abort and restart: print the error, call process.exit, and return a nonzero exit code so the deployment platform can restart the service. section 11.2.2
Log, then exit
Register process.on("uncaughtException", handler), log the stack through standard error, and call process.exit(1).
How Bootstrapping Microservices, Second Edition: With Docker, Kubernetes, GitHub Actions, and Terraform covers it
How deep it goes
Explains event handling, standard-error logging, exit codes, and restart consequences, but does not detail recovery procedures.
Examples
Uses process.on listings that either log an uncaught exception or log it before exiting with code 1.
What it assumes
Assumes basic Node.js error handling and try/catch knowledge while introducing process events and exit status behavior.
What you can do after
Operate/configure a Node.js service to report uncaught exceptions and deliberately resume or terminate with an error status.
How it connects
Connects uncaught exceptions to try/catch, the Node.js process object, standard error, process.exit, logging, and Kubernetes.
catch clausecontrasts with · A catch clause is an exception-handling construct that executes a handler when an associated operation raises a matching exception or error.
resumeconfigures · Resume is an error-handling strategy that allows processing to continue after an unexpected error, typically by skipping the failing operation or element.
telemetryuses · Telemetry is automatically generated or collected operational data describing a system’s activity, state, behavior, or performance.
This explainer was generated by Manning's knowledge graph from the text of Bootstrapping Microservices, Second Edition: With Docker, Kubernetes, GitHub Actions, and Terraform. The section links point to the parts of the book it draws on.