-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
PromiseRejectionEvent differs from Living Standard spec #1447
Comments
Bluebird fired these events for several years before browsers specified them so it uses a version that predates what the DOM settled on. Note that you can use |
That makes sense! Thanks for the explanation. Now that a standard has been defined, shouldn't bluebird adhere to it? It seems like it would be worth the breaking change as part of a major release. |
It can be done in backwards compatible way |
Bugsnag was having trouble picking up on Bluebird's unhandled rejection messages (see https://github.com/bugsnag/bugsnag-js/blob/master/src/bugsnag.js#L1285), hopefully #1464 fixes this! |
PR LGTM, @domenic can you please take a look and confirm this is compatible with the standard? |
I mean it's not exactly an implemenation of it, and differs in little ways (e.g. getter vs. data property) but if the goal is to be able to write code that works roughly the same in both, adding promise and reason properties to the event object seems reasonable. |
If we're doing this (which I think we should to ensure an easy transition from/to bluebird) I think we should actually implement the differences. Is there anything we can test against? (as in, are there tests for how the event is fired we can make sure we pass?) @nornagon would you be willing to change the code to getters? |
See #1464 (comment), would that be a better way of implementing this? |
Updated the PR to use getters. |
I don't feel that's realistic for a Node.js API? E.g. there's no Event class in Node.js, so you'll have to implement that whole hierarchy. Then you'll have to get rid of the
The tests were largely derived from the Node.js tests, but they live at https://github.com/w3c/web-platform-tests/tree/master/html/webappapis/scripting/processing-model-2/unhandled-promise-rejections |
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
Hello, Why was this issue closed?
Also, typescript would not allow solutions like that one that was mentioned above, unless we have some type to define the event that bluebird fires (searched in DefinitelyTyped and couldn't find). IMHO Bluebird should be aligned with the spec and trigger the event with PromiseRejectionEvent instance, for now, if there's type definition it could be really helpful. Thanks! |
The local unhandled rejection events and the global ones are separate and solve separate things. The last batch of differences was fixed in 8991667 This issue is misleading because it broke again before it was fixed. |
It's possible we haven't had a release with this yet because of the async_hook fears. @petkaantonov ? |
What version of bluebird is the issue happening on?
3.5.0
What platform and version? (For example Node.js 0.12 or Google Chrome 32)
Google Chrome 56.0
Did this issue happen with earlier version of bluebird?
Yes.
Bluebird seems to be creating a PromiseRejectionEvent with a 'detail' property, which contains 'promise' and 'reason' properties. TypeScript complains that PromiseRejectionEvent has no 'detail' property, which prompted me to look at the specification for this event. It appears that 'promise' and 'reason' are intended to be properties of the event object itself, e.g. event.promise and event.reason.
Perhaps I'm missing something?
Spec info found here -
https://developer.mozilla.org/en-US/docs/Web/API/PromiseRejectionEvent/PromiseRejectionEvent
https://html.spec.whatwg.org/multipage/webappapis.html#promiserejectionevent
The text was updated successfully, but these errors were encountered: