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

avoid unexpected unhandledRejection #1430

Closed
wants to merge 1 commit into from

Conversation

suguru03
Copy link
Contributor

@suguru03 suguru03 commented Aug 2, 2017

I fixed this issue. #1404
Could you review it?

I wanted to add these cases, but there is no async/await test case. Therefore I didn't. (If you want, I will add them..)

example 0

async function WaitAsync(){
    return Promise.reject(new Error("reject"));
}

Promise.resolve().then(() => {
    return WaitAsync();
}).catch(err => {
    console.log("caught: ", err.message);
});
caught:  reject

example 1

Promise.using(Promise.resolve(), async () => {
  await Promise.reject(new Error('foo'))
})
.catch(() => console.log('OK'))
OK

example 2

const reject = () => Promise.reject(new Error('foo'))

Promise.using(Promise.resolve(), async () => {
  await reject()
})
.catch(() => console.log('OK'))
OK

@STRML
Copy link

STRML commented Aug 22, 2017

@petkaantonov Please take a look - this is causing spurious logging in production applications.

@petkaantonov
Copy link
Owner

Thanks, same fix was already implemented. However it causes more issues because setTimeout is hijacked by some testing frameworks.

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

Successfully merging this pull request may close these issues.

3 participants