Open
Description
openedon Sep 9, 2021
Line 204 in bbf0c11
What is the use case for this code here?
I got surprised by seeing the handler executed twice whenever rejecting a promise. For example
it('runs example', () => {
Promise.reject('nobody handles me 😈 '); // reject once
process.on('unhandledRejection', (reason, promise) => {
console.log(' Rejection ', reason, JSON.stringify(promise)); // this shows up twice
});
})
I notice the handler was removed(line 198) before the rejection is emitted internally in mocha, but the event seems to be cached, which means the internal emit will trigger the handler to be called anyway right after it is added back (line 206).
Is it intended to be so (what is the use case if this is true) or it is some bug?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment