Node.js · Senior · Question 49 of 75
Why is uncaughtException + 'log and continue' a bad pattern?
- ✓Correct answer: After an unexpected throw, state may be corrupted (half-done updates, leaked resources); the safe path is log, stop accepting work and restart
- 2Logging inside
uncaughtExceptionis impossible - 3It makes the process exit twice
Explanation
Use the handler only for synchronous cleanup and logging, then exit with a non-zero code and let the orchestrator restart the process.