Bird
0
0

What happens if a promise rejection is not handled in a Node.js application?

easy📝 Conceptual Q1 of 15
Node.js - Error Handling Patterns
What happens if a promise rejection is not handled in a Node.js application?
ANode.js emits an 'unhandledRejection' event
BThe application automatically retries the promise
CThe promise resolves with a default value
DNode.js ignores the rejection silently
Step-by-Step Solution
Solution:
  1. Step 1: Understand promise rejection behavior

    When a promise is rejected and no catch handler is attached, Node.js detects this as an unhandled rejection.
  2. Step 2: Node.js event emission

    Node.js emits an 'unhandledRejection' event on the process object to notify the application about the unhandled rejection.
  3. Final Answer:

    Node.js emits an 'unhandledRejection' event -> Option A
  4. Quick Check:

    Unhandled promise rejection = emits 'unhandledRejection' event [OK]
Quick Trick: Unhandled rejections trigger 'unhandledRejection' event [OK]
Common Mistakes:
  • Assuming Node.js retries rejected promises automatically
  • Thinking unhandled rejections are ignored silently
  • Believing promises resolve with default values on rejection

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Node.js Quizzes