📌 Description
If src/index.ts doesn't register process.on('unhandledRejection', ...) / process.on('uncaughtException', ...), an unhandled async error can crash the process abruptly without draining connections or logging enough context to debug, instead of going through the existing graceful path in src/shutdown.ts.
🧩 Requirements and context
- Register both handlers in
src/index.ts, logging the error with full context (stack, request id if available).
- Route the crash through the existing shutdown sequence in
src/shutdown.ts rather than calling process.exit directly.
- Ensure the force-exit timeout guard still applies so a hung shutdown doesn't block forever.
🛠️ Suggested execution
- Add the two
process.on handlers in src/index.ts, invoking the shutdown function from src/shutdown.ts.
- Add a test that simulates an unhandled rejection and asserts shutdown is invoked.
✅ Acceptance criteria
🔒 Security notes
Ensure the logged error context doesn't include secrets (e.g. full request bodies with credentials).
📋 Guidelines
- Minimum 95% test coverage
- Clear documentation
- Timeframe: 96 hours
📌 Description
If
src/index.tsdoesn't registerprocess.on('unhandledRejection', ...)/process.on('uncaughtException', ...), an unhandled async error can crash the process abruptly without draining connections or logging enough context to debug, instead of going through the existing graceful path insrc/shutdown.ts.🧩 Requirements and context
src/index.ts, logging the error with full context (stack, request id if available).src/shutdown.tsrather than callingprocess.exitdirectly.🛠️ Suggested execution
process.onhandlers insrc/index.ts, invoking the shutdown function fromsrc/shutdown.ts.✅ Acceptance criteria
🔒 Security notes
Ensure the logged error context doesn't include secrets (e.g. full request bodies with credentials).
📋 Guidelines