Contact emails
joc...@chromium.org (implementation), d...@domenic.me (spec)
Spec: https://github.com/domenic/unhandled-rejections-browser-spec
This spec is mostly complete, but will require tweaking to the timing, which we hope to nail down through implementation experience. It also doesn’t yet specify how Worker objects should dispatch these events (like they currently do for error events).
Summary
We’d like to introduce a pair of events on the global object and on Worker instances, unhandledrejection and rejectionhandled, for tracking promise rejections.
Motivation
A common desire on the web is to log any uncaught exceptions back to the server. The typical method for doing this is
window.onerror = (message, url, line, column, error) => {
// log `error` back to the server
};
When programming asynchronously with promises, asynchronous exceptions are encapsulated as rejected promises. They can be caught and handled withpromise.catch(err => ...), and propagate up through an "asynchronous call stack" (i.e. a promise chain) in a similar manner to synchronous errors.
However, for promises, there is no notion of the "top-level" of the promise chain at which the rejection is known to be unhandled. Promises are inherently temporal, and at any time code that has access to a given promise could handle the rejection it encapsulates. Thus, unlike with synchronous code, there is not an ever-growing list of unhandled exceptions: instead, there is a growing and shrinking list of currently-unhandled rejections.
Our developer tools already expose this live list of currently-unhandled rejections, by interleaving them with synchronous exceptions and then graying them out and putting a checkmark next to them when/if they become handled. However, developer tools are not sufficient to satisfy the telemetry use case, i.e. the use case which is currently handled via window.onerror for synchronous code.
Compatibility Risk
This feature was discussed on the WHATWG list last September, with helpful engagement from Mozilla. I asked again recently to see if there was any support and got a more explicit statement of support from them, alongside some feedback that has shaped the API direction.
There have been no signs from other vendors. (Indeed, other vendors do not yet have devtools-based promise rejection tracking.)
Ongoing technical constraints
None.
Will this feature be supported on all six Blink platforms (Windows, Mac, Linux, Chrome OS, Android, and Android WebView)?
Yes.
OWP launch tracking bug?
https://code.google.com/p/chromium/issues/detail?id=495801
Link to entry on the feature dashboard
https://www.chromestatus.com/feature/4805872211460096
Requesting approval to ship?
No.To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+...@chromium.org.