-
Notifications
You must be signed in to change notification settings - Fork 386
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 errors #311
Comments
Not even sure if chrome implementation is valid, i.e. are you supposed to be able to attach catch handlers asynchronously? |
Yes, you are supposed to be able to attach catch handlers asynchronously. But I think Chrome is supposed to remove the message from console if that happens, or something like that? It would be nice to chain through native promises. The most straightforward way to do that would be to subclass them.... but of course that's what Chrome isn't supporting yet. Boo. |
I wonder if it would be worth it, in the case where there's a native At any rate, the Chrome behavior of console warning when you forget |
@ljharb , |
@ljharb what's the status of proxy support in browsers? My initial thought was that maybe our Promise implementation could attach a "native" promise to the end of its promise chain, and then remove it as soon as then/catch was called (since there would presumably be a new native promise chained after that). This ought to preserve the browser's "uncaught exception" behavior, although perhaps it wouldn't capture the stack. It would also have a performance impact, although perhaps that would be slight. |
I don't think anything has proxies yet. That's definitely a use case for it though. |
@ljharb I cannot understand this issue, but
this causes a error message in the log in Chrome. And if replace |
@Yaffle yes, many utility libraries for Promises (such as http://github.com/cscott/prfun) add a There's also a web spec in-process for triggering the "uncaught promise exception" handler in the same way that there is an "uncaught exception" handler in the web stack for synchronous code. I don't know if Chrome has exposed this to users yet, though. If they have, we could hook it. |
The try catch around line 1867 is currently eating all my Promise errors (in the |
@AlastairTaft I'm not sure what you mean - that's what native Promises do by spec. All Promises swallow all errors, and the only way to catch them is with a The additional browser behavior of notifying the console when you have an unhandled rejection is not part of the spec, it's bonus behavior some promises provide. |
@ljharb If it's by design then no worries. I'll provide some code though to explain my point a bit better just encase it is a problem. So I'm doing something like this in my code
When I hit a run time error in the |
Correct. You can never throw an error outside of a Promise - that's how they work everywhere. You can do Handle the error in the right place: inside the promise :-) |
Fair enough :) |
The |
At least for debug versions I have changed the rejectPromise (line 1913) function like below, otherwise finding an error almost impossible.
|
Currently, if there's no
.catch
errors will vanish mysteriously. Native promises in chrome 41.0.2249.0 (current canary) will print a message about unhandled promise errors:but if the es6-shim is loaded, it clobbers the native Promise because it doesn't seem to support subclassing, and replaces it with an insidious version with total error suppression:
Not sure what the best approach is to solve this.
The text was updated successfully, but these errors were encountered: