Bird
0
0

What happens if you call process.exit() immediately inside an 'uncaughtException' handler without closing server connections?

medium📝 component behavior Q5 of 15
Node.js - Error Handling Patterns
What happens if you call process.exit() immediately inside an 'uncaughtException' handler without closing server connections?
AServer may terminate abruptly, causing dropped connections
BServer closes connections gracefully before exit
Cprocess.exit() is ignored and server keeps running
DNode.js automatically retries the request
Step-by-Step Solution
Solution:
  1. Step 1: Understand process.exit behavior

    Calling process.exit() immediately stops the process without waiting for cleanup.
  2. Step 2: Effect on server connections

    Without closing connections first, they may drop abruptly causing client errors.
  3. Final Answer:

    Server may terminate abruptly, causing dropped connections -> Option A
  4. Quick Check:

    Immediate exit causes abrupt termination [OK]
Quick Trick: Close connections before exit to avoid abrupt termination [OK]
Common Mistakes:
  • Assuming exit waits for cleanup
  • Thinking Node retries requests
  • Believing exit is ignored

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Node.js Quizzes