GeezerVison is showing github.com — 'uncaughtException' event not working with unhandled promises · Issue #32907 · nodejs/node
'uncaughtException' event not working with unhandled promises #32907Labels docIssues and PRs related to Node.js documentation. Description
- Version: 13.3.0
- Platform: Win 10 64-bit
- Subsystem: Process
What steps will reproduce the bug?
process.on('uncaughtException', (err, origin) =>
{
console.log('catch: ' + err.message + ' | ' + origin);
console.log();
});
examplePromise();
function examplePromise()
{
return Promise.reject('Test');
}
What is the expected behavior?
According to the documentation default node handling should be overwritten by this callback with unhandledRejection origin
What do you see instead?
(node:14784) UnhandledPromiseRejectionWarning: Test
(node:14784) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:14784) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Additional information
I think that is probably an error that documentation and origin variable suggests that uncaughtException can handle promises when we have unhandledRejection event. Activitycjihrig commented on Apr 17, 2020 You have an unhandled rejection, not an uncaught exception. They aren't the same thing. You could try looking into the --unhandled-rejections CLI flag though. The strict mode should do what you want. cjihrig commented on Apr 17, 2020 FWIW, I just read through the docs, and I agree that they are confusing in this regard. Reacted by Michaël Zasso, Mark and Brent Williams MrBartusek commented on May 1, 2020 I see that this issue is inactive so to work on any fix the more information are needed:
- What is the purpose of origin?
- Why according to documentation there are two ways to handle the same thing
unhandledRejection (origin argument) and unhandledRejection (event)
- Is that documentation issue or codebase issue?
BridgeAR commented on May 25, 2020 @MrBartusek I opened #33530 to improve the documentation. Does that clarify the origin argument and the purpose of it? MrBartusek commented on May 25, 2020 @BridgeAR Yes! That clarifies everything, thanks
MetadataMetadatadocIssues and PRs related to Node.js documentation. DevelopmentNo branches or pull requestsIssue actions
|