Skip to content

Unhandled promise rejection deprecation message is printed even when there's an unhandledRejection listener #28539

@nwoltman

Description

@nwoltman
  • Version: v12.6.0
  • Platform: Windows
  • Subsystem: lib

The unhandled promise rejection deprecation message is printed even when a promise rejection error is handled by an unhandledRejection listener.

The following program did not produce a deprecation warning with Node 12.5.0, but it does now with Node 12.6.0:

process.on('unhandledRejection', (err) => {
  console.log('Handled rejection:', err.message);
});

Promise.reject(new Error('rejection error'));

Output:

Handled rejection: rejection error
(node:17332) [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.

Expected output:

Handled rejection: rejection error

This issue may have been caused by #28258.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions