Skip to content

Instantly share code, notes, and snippets.

@Silent-Watcher
Created June 27, 2025 21:03
Show Gist options
  • Save Silent-Watcher/a70080d3ca2a74e4c5967be8b5640338 to your computer and use it in GitHub Desktop.
Save Silent-Watcher/a70080d3ca2a74e4c5967be8b5640338 to your computer and use it in GitHub Desktop.
The Silent Killers in Node.js: uncaughtException and unhandledRejection
✅ Do ❌ Don’t
Log full stack traces and context (request IDs, payloads, etc.) Continue running as if nothing happened
Report to external error‑tracking services (Sentry, Datadog, etc.) Swallow errors or leave handlers empty
Gracefully shut down: close DB, stop accepting new requests Call process.exit(0) (signals success)
Use a supervisor (e.g., PM2, Docker restart policy) Believe you can recover 100% safely in‑process
Convert unhandled rejections into exceptions (throw reason) Ignore Node.js v15+ default behavior—explicit is better
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment