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

"async & performance": Document unhandled rejection hooks #348

Open
benjamingr opened this issue Feb 25, 2015 · 4 comments
Open

"async & performance": Document unhandled rejection hooks #348

benjamingr opened this issue Feb 25, 2015 · 4 comments
Assignees

Comments

@benjamingr
Copy link

@benjamingr benjamingr commented Feb 25, 2015

In async & performance you mention promise rejections and debuggability with error handling. A patch has landed in io.js in 1.4 which is released tomorrow with native promises that lets you do something similar to your example:

Your example syntax:

var p = Promise.reject( "Oops" ).defer();
var p2 = Promise.reject( "Oops" ); // will be reported as an unhandled rejection to the console

Can now be coded with

var p = Promise.reject( "Oops" ).catch(function(){});
var p2 = Promise.reject( "Oops" ); // will be reported as an unhandled rejection to the console

When doing:

process.on("unhandledRejection", function(promise, reason) {
    console.log("Unhandled Error", reason);
});

This will achieve semantics very close to your .defer semantics using native ES6 promises in io.js, I think it's worth mentioning :) How do you feel about this?

@getify

This comment has been minimized.

Copy link
Owner

@getify getify commented Feb 25, 2015

Unfortunately, the book is already off to press now, so it's too late to sneak in anything for first edition. But it's worth keeping this around to see how it shakes out. AFAIK, this unhandledRejection thing is not ES6 spec related, but a hosting-environment extension. I'd want to document it if it fully takes off as the de facto standard of how promise rejections are handled across browsers and ssjs's.

@getify getify self-assigned this Feb 25, 2015
@benjamingr

This comment has been minimized.

Copy link
Author

@benjamingr benjamingr commented Feb 25, 2015

Yeah, it's not ES6 spec related - it's implemented on the serverside and there is a similar proposal for window.onerror

@getify getify changed the title Document unhandled rejection hooks "async & performance": Document unhandled rejection hooks Jun 29, 2015
@benjamingr

This comment has been minimized.

Copy link
Author

@benjamingr benjamingr commented Apr 8, 2016

Just updating that it's also in the DOM now as window.addEventListener("unhandledrejection", ...

@getify

This comment has been minimized.

Copy link
Owner

@getify getify commented Apr 9, 2016

thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Second Edition
Async & Performance
2 participants
You can’t perform that action at this time.