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

Browser rejection hook #106

Closed
benjamingr opened this issue Sep 9, 2015 · 5 comments
Closed

Browser rejection hook #106

benjamingr opened this issue Sep 9, 2015 · 5 comments

Comments

@benjamingr
Copy link
Contributor

Hey, it would be great for us if you exposed the process unhandledRejection hook event somehow to browsers, this is useful for logging errors and handling problems.

Alternatively, if you make the isNode check overridable.

@zloirock
Copy link
Owner

Awaiting proposals how do it w/o breaking current default behavior and adding process module to browser bundles for all users. Or you mean this?

@benjamingr
Copy link
Contributor Author

The problem is that it's a lot of code to run these browser events in old browsers. I think even just adding a window.onpossiblyunhandledrejection and not guaranteeing it will stay around is immensely useful.

@zloirock
Copy link
Owner

You mean simple

if(isNode){
  process.emit('unhandledRejection', reason, promise);
} else if(global.onunhandledrejection){
  global.onunhandledrejection({promise: promise, reason: reason});
} else if(global.console && console.error){
  console.error('Unhandled promise rejection', reason);
}

?

@benjamingr
Copy link
Contributor Author

That would work and definitely aid a ton of people in debugging.

The main use case is that we have to include a bigger library (like bluebird) if we want any form of reporting of client side errors - which are useful in order to track errors users get so we can fix them.

@zloirock
Copy link
Owner

Ok, I will add it.

Warning: The problem here - we can't add it to native Promise implementations, but by idea core-js should use enough correct native implementation if it's available. Currently, most native implementations are buggy and core-js uses polyfill, but the situation will be changed. If someone wanna use this hook everywhere - he should delete window.Promise before inclusion core-js.

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

No branches or pull requests

2 participants