Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'uncaughtException' event not working with unhandled promises #32907

Closed
MrBartusek opened this issue Apr 17, 2020 · 5 comments
Closed

'uncaughtException' event not working with unhandled promises #32907

MrBartusek opened this issue Apr 17, 2020 · 5 comments
Labels
doc Issues and PRs related to the documentations.

Comments

@MrBartusek
Copy link

  • 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.

@cjihrig
Copy link
Contributor

cjihrig commented 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
Copy link
Contributor

cjihrig commented Apr 17, 2020

FWIW, I just read through the docs, and I agree that they are confusing in this regard.

@MrBartusek
Copy link
Author

I see that this issue is inactive so to work on any fix the more information are needed:

  1. What is the purpose of origin?
  2. Why according to documentation there are two ways to handle the same thing unhandledRejection (origin argument) and unhandledRejection (event)
  3. Is that documentation issue or codebase issue?

@BridgeAR BridgeAR added the doc Issues and PRs related to the documentations. label May 23, 2020
BridgeAR added a commit to BridgeAR/node that referenced this issue May 23, 2020
The `uncaughtException` listener's origin argument was ambiguous
about unhandled rejections. This should clarify when origin is set
to `'unhandledRejection'`.

Fixes: nodejs#32907

Signed-off-by: Ruben Bridgewater <ruben@bridgewater.de>
@BridgeAR
Copy link
Member

@MrBartusek I opened #33530 to improve the documentation. Does that clarify the origin argument and the purpose of it?

@MrBartusek
Copy link
Author

@BridgeAR Yes! That clarifies everything, thanks

codebytere pushed a commit that referenced this issue Jun 18, 2020
The `uncaughtException` listener's origin argument was ambiguous
about unhandled rejections. This should clarify when origin is set
to `'unhandledRejection'`.

Fixes: #32907

Signed-off-by: Ruben Bridgewater <ruben@bridgewater.de>

PR-URL: #33530
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
codebytere pushed a commit that referenced this issue Jun 30, 2020
The `uncaughtException` listener's origin argument was ambiguous
about unhandled rejections. This should clarify when origin is set
to `'unhandledRejection'`.

Fixes: #32907

Signed-off-by: Ruben Bridgewater <ruben@bridgewater.de>

PR-URL: #33530
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
codebytere pushed a commit that referenced this issue Jul 8, 2020
The `uncaughtException` listener's origin argument was ambiguous
about unhandled rejections. This should clarify when origin is set
to `'unhandledRejection'`.

Fixes: #32907

Signed-off-by: Ruben Bridgewater <ruben@bridgewater.de>

PR-URL: #33530
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc Issues and PRs related to the documentations.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants