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

Wrong unhandledRejection event #1912

Closed
waldreiter opened this issue Jun 7, 2015 · 9 comments
Closed

Wrong unhandledRejection event #1912

waldreiter opened this issue Jun 7, 2015 · 9 comments

Comments

@waldreiter
Copy link

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.

@petkaantonov
Copy link
Contributor

Without checking I would say this is a bug in V8 for not firing kPromiseHandlerAddedAfterReject when a rejected promise is followed.

@mscdex mscdex added the v8 engine Issues and PRs related to the V8 dependency. label Jun 7, 2015
@benjamingr
Copy link
Member

@cody does the rejectionHandled event get called too?

@benjamingr
Copy link
Member

I can't reproduce this in my platform - I only get catch: reject - which version of io.js are you running?

Update: Nevermind, this reproduces just fine.

@targos
Copy link
Member

targos commented Jun 10, 2015

@benjamingr what is your platform ?
I can reproduce on win64. Result with rejectionHandled added:

D:\Desktop>node -v
v2.2.1

D:\Desktop>node test
catch: reject
unhandledRejection: reject
rejectionHandled: Promise { <rejected> 'reject' }

@benjamingr
Copy link
Member

Who needs to be pinged on the v8 team?

@thefourtheye
Copy link
Contributor

Can we start with @domenic?

@domenic
Copy link
Contributor

domenic commented Jun 11, 2015

Before calling this a V8 bug, we need a repro that is independent of the io.js code and just uses the V8 APIs.

@targos
Copy link
Member

targos commented Jun 11, 2015

FWIW, the bug cannot be reproduced in Chrome's console

@vkurchatkin vkurchatkin removed the v8 engine Issues and PRs related to the V8 dependency. label Jun 11, 2015
vkurchatkin added a commit to vkurchatkin/node that referenced this issue Jun 12, 2015
Fixes: nodejs#1912
PR-URL: nodejs#1952
Reviewed-By: Domenic Denicola <[email protected]>
Reviewed-By: Petka Antonov <[email protected]>
@vkurchatkin
Copy link
Contributor

This issue should be fixed by a251657

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants