Node.js · Middle · Question 21 of 75
What happens if an EventEmitter emits error and there is no error listener?
- 1The event is ignored
- 2Node.js logs a warning and continues
- ✓Correct answer: The error is thrown, which usually crashes the process
Explanation
The error event is special. Always add an error listener to streams, sockets and servers, or use pipeline and events.once, which turn it into a rejection.