You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
unexpected behavior with --unhandled-rejections=strict flag #41184
when we use flag --unhandled-rejections=strict we expect not to see any UnhandledPromiseRejectionWarning and Raise the unhandled rejection as an uncaught exception. but:
node --unhandled-rejections=strict test.js
Exception
(node:83740) UnhandledPromiseRejectionWarning: undefined
(Use `node --trace-warnings ...` to show where the warning was created)
(node:83740) 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(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
and when we do not use --unhandled-rejections=strict flag:
node test.js
Exception
How often does it reproduce? Is there a required condition?
This comment indicates that the warning is expected when using 'strict' mode if you handle the uncaught exception. I've opened #41194 to update the docs.
It has different behavior in node v14
I wasn't able to reproduce this with the 'strict' flag. Did you mean that the default behavior (no flag specified) switched between v14 and v16? If so, that is expected behavior.
@cjihrig yes default behavior is different between node v14.18.2 and v16.13.1 but documents was not up to date. and that was confusing...
actually node v16.13.1 Raise the unhandled rejection as an uncaught exception by default.
Activity
doc: add unhandledRejection to strict mode
cjihrig commentedon Dec 16, 2021
This comment indicates that the warning is expected when using
'strict'mode if you handle the uncaught exception. I've opened #41194 to update the docs.I wasn't able to reproduce this with the
'strict'flag. Did you mean that the default behavior (no flag specified) switched between v14 and v16? If so, that is expected behavior.guoard commentedon Dec 16, 2021
@cjihrig yes default behavior is different between node v14.18.2 and v16.13.1 but documents was not up to date. and that was confusing...
actually node v16.13.1 Raise the unhandled rejection as an uncaught exception by default.
doc: add unhandledRejection to strict mode
doc: add unhandledRejection to strict mode
doc: add unhandledRejection to strict mode
doc: add unhandledRejection to strict mode
abhayb443 commentedon Oct 19, 2022
export NODE_OPTIONS=--unhandled-rejections=none
from the terminal
or
In npmrc file in the project
node-options="--unhandled-rejections=none"
to resolve this error. It will stop prompting the error.