-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
Node and IO silently exits when error thrown in promise catch #600
Comments
Thanks for the report! In fact all throws inside promise handlers are caught by promises themselves: new Promise(function (f, r) {
throw new Error('Weee');
}).catch(function (ex) {
throw new Error('Fuuu');
}).catch(function(){
console.log('hey');
}); The problem is that currently there is no mechanism to deal with unhandled promise rejections, so they are silently ignored. This issue is tracked here: #256 Closing as a duplicate. |
Oh, I thought it was handled if I provide catch, but it will create yet another promise, so makes sense. I looked at how Chrome is working with my example and it seems that there is no difference from developer stand point if code executes like above, or like that: new Promise(function (f, r) {
throw new Error('Weee');
}).catch(function (ex) {
setTimeout(function () {throw new Error('Fuuu');}, 0);
}); Later is working as expected in node & io, so I'll use that pattern from now on. |
@szarouski note that in promise libraries like bluebird this is not a silent failure but is reported with a stack trace to the console. |
Run this code in iojs
You'll get an error and a minimal stack trace in console.
Run following code in iojs
You'll get nothing, even though catch function definitely executes (you can try adding console.log in there)
I'm not sure sure how it is supposed to work, but looks suspicious.
The text was updated successfully, but these errors were encountered: