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

Handle Bluebird unhandledrejection #7

Closed
wants to merge 1 commit into from

Conversation

brenthompson
Copy link

Bluebird.js promises don't have event.reason, they instead have event.detail.reason. An unhanded rejection from bb causes an exception from your plugin. Given Bluebird's popularity it's probably worthwhile handing this case at least until they fix their side. As you can see they've taken a couple of kicks at this already. Links to their issues:
petkaantonov/bluebird#1447
petkaantonov/bluebird#1509

Bluebird.js promises don't have event.reason, they instead have event.detail.reason. An unhanded rejection from bb causes an exception from your plugin. Given Bluebird's popularity it's probably worthwhile handing this case at least until they fix their side. As you can see they've taken a couple of kicks at this already. Links to their issues:
petkaantonov/bluebird#1447
petkaantonov/bluebird#1509
@@ -72,7 +72,7 @@ module.exports = options => {
}, 200);
window.addEventListener('unhandledrejection', event => {
event.preventDefault();
rejectionHandler(event.reason);
rejectionHandler(event.reason || event.detail.reason);
Copy link

@nmccready nmccready Apr 23, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of covering all the possible unique cases of different event.reasons should this not become an option? IE do something like this?

options.eventReasonPath = ['reason']; // default

rejectionHandler(get(event, options.eventReasonPath)) ??

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, libraries should just follow the standard.

@sindresorhus
Copy link
Owner

I appreciate the PR, but I'm not interested in adding this. Bluebird should follow the Promise spec. Adding support for weird behavior in custom Promise libraries is a slippery slope.

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.

None yet

3 participants