Node.js · Junior · Question 68 of 75
What happens when an error is thrown and nothing catches it?
- 1Node.js ignores it and continues
- ✓Correct answer: The
uncaughtExceptionevent fires and by default the process prints the stack and exits - 3Node.js restarts the script automatically
Explanation
After an uncaught exception the app may be in a broken state, so the safe approach is to log it and let a process manager (systemd, Docker, Kubernetes, PM2) restart the app.