-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Unhandled promise rejections doesn't emit unhandledRejection event in the browser #205
Comments
Yep, it still not implemented. I'll add it later. Feel free add a PR. |
Hey, was just going to have a go implementing this, but didn't realise there is no polyfill for event/custom event for the reasons described here #354. So not really sure how to resolve this. Also it seems like maybe a large refactor to implement, here is my naive attempt with comments on why it wouldn't work: if(isUnhandled(promise)){
if(isNode){
process.emit('unhandledRejection', value, promise);
} else {
/**
This is required to call onunhandledrejection on any browser except chrome
but using in chrome this will cause it to be called twice as it
will also be triggered when the event is dispatched on the window.
*/
if(handler = global.onunhandledrejection){
handler({promise: promise, reason: value});
}
// This doesn't work in IE11-
var unhandledRejectionEvent = new Event('unhandledrejection');
unhandledRejectionEvent.promise = promise;
unhandledRejectionEvent.reason = value;
global.dispatchEvent(unhandledRejectionEvent)
}
// Also what condition should be used to determine logging like:
// console.error('Unhandled promise rejection', value);
} record.a = undefined; I don't really have much experience with older browser quirks, so some help would be appreciated. |
You should be able to use |
Added to v3 branch. |
Using
babel-polyfill
, it seems I'm unable to catch promise rejections with this syntax:However I'm able to catch them with
I think it's related to this line:
core-js/library/modules/es6.promise.js
Line 116 in add384d
The text was updated successfully, but these errors were encountered: