Skip to content

unexpected behavior with --unhandled-rejections=strict flag #41184

Closed
@guoard

Description

@guoard

Version

v16.13.1

Platform

Linux 5.11.0-41-generic #45~20.04.1-Ubuntu SMP Wed Nov 10 10:20:10 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

Subsystem

No response

What steps will reproduce the bug?

// test.js
process.on('uncaughtException', () => {
  console.log('Exception');
});

Promise.reject()

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?

No response

What is the expected behavior?

It should do exactly the opposite

What do you see instead?

No response

Additional information

It has different behavior in node v14

Metadata

Metadata

Assignees

No one assigned

    Labels

    docIssues and PRs related to the documentations.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions