-
-
Notifications
You must be signed in to change notification settings - Fork 33.5k
Closed
Labels
promisesIssues and PRs related to ECMAScript promises.Issues and PRs related to ECMAScript promises.
Description
- Version: 8+ (probably all versions that supports
unhandledRejection
event) - Platform: linux
- Subsystem: process
According to documentation of uncaughtException
- 'Exceptions thrown from within the event handler will not be caught. Instead the process will exit with a non-zero exit code and the stack trace will be printed. This is to avoid infinite recursion.'.
So why unhandledRejection
allows you to fall into infinite recursion if code within handler creates unhandled promise rejection ? I expect the same behavior as for uncaughtException
(exit process with non-zero code).
unhandledRejection
handler may contain some logic to log that situation, and owing to the fact that 3-d party logger implementation can produce unhandled rejection within himself , we can have infinite recursion.
Code example to reproduce:
'use strict';
process.on('unhandledRejection', uncaughtRejection => {
console.log('unhandledRejection handler catch: ' + uncaughtRejection);
Promise.reject(3);
});
function foo() {
return Promise.reject(1);
}
foo();
Thanks in advance.
Metadata
Metadata
Assignees
Labels
promisesIssues and PRs related to ECMAScript promises.Issues and PRs related to ECMAScript promises.