-
Notifications
You must be signed in to change notification settings - Fork 64
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
Integrate with window.onerror #49
Comments
FYI: there are 2 web-platform test cases failed after supporting this in Firefox [1]: Expecting this to be specified eventually in IDB Spec v2. |
Yes, I'll get around to specifying it soon. (Chrome impl still blocked on performance regression, since capturing source location is not free. I need to push on the v8 team.) |
@bevis-tseng - would this capture the FF behavior? In the definition of request, add the properties script and position which capture the script and position from which the call which created the request was made, the property context which is the global object specified by the script's settings object. At the end of 5.10 Firing an error event add a step: If the event’s canceled flag is not set, report an error with request's script, position, and context. Add a similar substep to open() and deleteDatabase() Any particular notes about ordering? If preventDefault() is called on the ErrorEvent seen in onerror, does that prevent the transaction from aborting? |
Does report an error do the right thing when the error happens in a dedicated worker? I.e. does an error event fired against a worker global have a default action of firing an error event on the |
Yes, this captures the behavior in FF. |
Note that in a worker, the propagation path in Firefox is IDBRequest -> IDBTransaction ->IDBDatabase => Worker global => Worker object => Window global In the above, "->" indicates a single Since Firefox support nested workers, the propagation path can even be IDBRequest -> IDBTransaction ->IDBDatabase => Worker 2 global => Worker 2 object => Worker 1 global => Worker 1 object => Window global Where "Worker 2" is a nested worker inside of "Worker 1" |
I don't suppose anyone else wants to take a stab at specifying this and submitting a PR? Fame and glory await... |
We should update the definitions error events from |
In the specification, I assume both The latter would be harder to faithfully polyfill, however, as one would need to overwrite any user |
Apologies, I hadn't been aware that there was |
Although this might be covered by the normal DOM behavior with exceptions in handlers triggering the global |
I'm going to punt this to v3, since we have implementations claiming "v2" support without this and it's a normative addition. Gecko still gets 🥇 |
To test/spec: When IDBCursor's |
In the new DOM hook for IndexedDB,
This 'reporting the exception' step itself mentions it needing to "report the error" with the "global object" which would thus appear to trigger
So, it looks like:
|
This issue is about having errors on requests be reported to global onerror; the "Report the exception" in the DOM algorithm mentioned above would apply if an exception is thrown in a callback. Contrast: store.put(v, k).onsuccess = e => {
throw Error('hello world'); // will invoke window.onerror handler
}; and: store.add(v, k);
store.put(v, k).onerror = e => {
console.warn('this will appear'); // will not invoke window.onerror handler
}; |
Note: Hence, for the case of store.put(v, k).onerror = e => {
console.warn('this will appear'); // will not invoke window.onerror handler
}; window.onerror will still be invoked if e.preventDefault() is not invoked in this onerror callback. |
Oh, yes. FF has already taken the leap and implemented (years ago!). I need to spec. :) |
It looks like we're unblocked from landing this on the Blink side on the performance front. To Do list:
|
The propagation from workers to window does not appear to behave as described in #49 (comment) in Firefox 57 for Indexed DB errors. Given a page with a worker that uses IDB that has handlers for the request, transaction, connection, a global onerror handler in the worker, an onerror handler on the Worker object, and an onerror handler on the window global scope, Firefox sees the following when a ConstraintError is triggered:
(i.e. the propagation path is just IDBRequest → IDBTransaction → IDBDatabase ⇒ Worker global) In contrast, for a non-IDB error, e.g. the script ends with
(i.e. the propagation path is Worker global ⇒ Worker object ⇒ Window global) Further, on the worker's global onerror, the first argument passed is the Error not the Event. That means @bevis-tseng - can you confirm the above, and if this is intentional? |
We disabled it temporary in bug 1389913 since this was not available yet in spec v2. In addition, only the error event originally targeted to an IDBRequest will be propagated in this way. |
Is there still interest in pursuing this, either from developers or implementers? Pro:
Con:
|
I don't think we have a strong opinion on the Firefox side at this time. My inclination would be to stick with the status quo (which translates to "do not pursue this"). My rationale is:
|
I agree with @asutherland. Let's stick with the status quo. At this point, I've accepted that any non-trivial use of IndexedDB will be wrapped by a library. Said library can deal with error handling. |
Closing out. |
This has never been documented/tested anywhere and has always been disabled since its start in 2017 in bug 1389913. This removes the pref as w3c/IndexedDB#49 decided not to propagate to window.onerror in 2019. Differential Revision: https://phabricator.services.mozilla.com/D151503
This has never been documented/tested anywhere and has always been disabled since its start in 2017 in bug 1389913. This removes the pref as w3c/IndexedDB#49 decided not to propagate to window.onerror in 2019. Differential Revision: https://phabricator.services.mozilla.com/D151503
This has never been documented/tested anywhere and has always been disabled since its start in 2017 in bug 1389913. This removes the pref as w3c/IndexedDB#49 decided not to propagate to window.onerror in 2019. Differential Revision: https://phabricator.services.mozilla.com/D151503
This has never been documented/tested anywhere and has always been disabled since its start in 2017 in bug 1389913. This removes the pref as w3c/IndexedDB#49 decided not to propagate to window.onerror in 2019. Differential Revision: https://phabricator.services.mozilla.com/D151503
If errors are not prevented, call window.onerror
The text was updated successfully, but these errors were encountered: