Skip to content

Wrong unhandledRejection event #1912

Closed
Closed
@waldreiter

Description

@waldreiter

The following program reproduces my problem:

const process = require('process');

process.on('unhandledRejection', function(reason) {
  console.log('unhandledRejection:', reason);
});

Promise
  .resolve('resolve')
  .then(function() {
    return Promise.reject('reject');
  })
  .catch(function(e) {
    console.log('catch:', e);
  });

// Promise.reject().catch(function(){});

This is the output:

catch: reject
unhandledRejection: reject

First the catch handler gets called, which is expected. But after that the unhandledRejection event handler gets called too, which is unexpected to me.

If the // on the last line are removed, then the unhandledRejection event handler gets not called. This line should have no effect on the first promise, but apparently it has.

Tested with v2.2.1 on OSX and linux.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions