Intent to implement and ship: 'window.onerror'/ErrorEvent improvements.

151 views
Skip to first unread message

Mike West

unread,
Jul 25, 2013, 9:08:57 AM7/25/13
to blink-dev

Contact emails

mk...@chromium.org


Spec

http://www.whatwg.org/specs/web-apps/current-work/#runtime-script-errors


Summary

I'd like to make three changes to our implementation of 'window.onerror'/ErrorEvent:


1. Skip sanitization for exceptions thrown from cross-origin scripts that were served with appropriate CORS headers.

2. Add the 'column' attribute to ErrorEvent.

3. Add the 'error' attribute to ErrorEvent, and pass it into the 'window.onerror' handler as the 5th parameter.

Motivation

Developers (especially those working on larger sites/applications) have a hard time debugging errors that happen in the wild with the tools we're currently offering to them. Many developers serve JavaScript from a CDN, which means that they get only sanitized errors in global handlers: they know an error occurred, but have no mechanism for tracking down where or why. Serving JS files with CORS headers can alleviate security/privacy concerns around data leakage, and enable better debugging possibilities. Likewise, some mechanism for obtaining stack traces would be useful: we (along with other evergreen browsers) expose a 'stack' property on exception objects. Doing the same for global event handlers (again, subject to CORS restrictions) seems like a great way of helping developers track down and fix issues.


Facebook's comments[1][2] are illustrative, and a variety of libraries have cropped up to attempt to provide the detailed, centralized error reporting functionality that we're currently failing to offer via 'window.onerror'. We should provide the functionality natively.


Compatibility Risk


#1 is low risk: WebKit[3] and Firefox[2] have already implemented the feature, we'd simply be matching their behavior.


#2 is unfortunate: IE has shipped with a property on the ErrorEvent interface named 'col'. The specification (and sanity) suggests 'column'. Christophe already landed a patch to pass the column number to the 'window.onerror' handler, but avoided doing so for the ErrorEvent interface because of this concern[4].


#3 is moderately risky: Firefox wants to add stack traces[5], there are apparently reasonable workarounds in IE[6]. While some WebKit contributors are positive on the feature[7], Apple has WONTFIXed it[8]. That said, the objections were partially standards-related: since Hixie added the 'error' bits to the spec this morning[9] after a few long threads, I'm hopeful that WebKit might come on board eventually.


I don't see any of these concerns as blockers, given the usefulness of the features in helping developers track down errors. I'm very interested in blink-dev@'s opinion (and those of our API owner overlords) however. :)

Ongoing technical constraints

No.


Will this feature be supported on all five Blink platforms (Windows, Mac, Linux, Chrome OS and Android)?

Yes.


OWP launch tracking bug?


CORS support: http://crbug.com/159566

'column' parameter: http://crbug.com/264197

'error' parameter: http://crbug.com/147127



Row on feature dashboard?

No. This seems like a very small feature: I'm only sending an intent to implement because of the IE weirdness with #2, and Apple's objection to #3.


Requesting approval to ship?

Yes.

[3]: https://bugs.webkit.org/show_bug.cgi?id=70574

-Mike

Christophe Dumez

unread,
Jul 25, 2013, 10:05:10 AM7/25/13
to Mike West, blink-dev
On Thu, Jul 25, 2013 at 4:08 PM, Mike West <mk...@chromium.org> wrote:

Contact emails

mk...@chromium.org


Spec

http://www.whatwg.org/specs/web-apps/current-work/#runtime-script-errors


Summary

I'd like to make three changes to our implementation of 'window.onerror'/ErrorEvent:


1. Skip sanitization for exceptions thrown from cross-origin scripts that were served with appropriate CORS headers.

2. Add the 'column' attribute to ErrorEvent.

3. Add the 'error' attribute to ErrorEvent, and pass it into the 'window.onerror' handler as the 5th parameter.

Motivation

Developers (especially those working on larger sites/applications) have a hard time debugging errors that happen in the wild with the tools we're currently offering to them. Many developers serve JavaScript from a CDN, which means that they get only sanitized errors in global handlers: they know an error occurred, but have no mechanism for tracking down where or why. Serving JS files with CORS headers can alleviate security/privacy concerns around data leakage, and enable better debugging possibilities. Likewise, some mechanism for obtaining stack traces would be useful: we (along with other evergreen browsers) expose a 'stack' property on exception objects. Doing the same for global event handlers (again, subject to CORS restrictions) seems like a great way of helping developers track down and fix issues.


Facebook's comments[1][2] are illustrative, and a variety of libraries have cropped up to attempt to provide the detailed, centralized error reporting functionality that we're currently failing to offer via 'window.onerror'. We should provide the functionality natively.


Compatibility Risk


#1 is low risk: WebKit[3] and Firefox[2] have already implemented the feature, we'd simply be matching their behavior.


#2 is unfortunate: IE has shipped with a property on the ErrorEvent interface named 'col'. The specification (and sanity) suggests 'column'. Christophe already landed a patch to pass the column number to the 'window.onerror' handler, but avoided doing so for the ErrorEvent interface because of this concern[4].

 
Just a small correction, as stated in my CL and based on my testing, IE10 (I haven't checked IE11 but it is likely to be the same) uses 'colno', not 'col'. At least, the naming IE10 uses is consistent with the existing 'lineno' ErrorEvent attribute even though different than what is in the specification.

I find it a bit inconsistent in the specification to use 'lineno' / 'column' but maybe it is just me. I would have used 'line' / 'column' or 'lineno' / 'colno' (like IE10).

Kr,
--
Christophe DUMEZ

Michael Davidson

unread,
Jul 25, 2013, 12:19:05 PM7/25/13
to Mike West, blink-dev
Just to chime in, as a web developer this:


On Thu, Jul 25, 2013 at 6:08 AM, Mike West <mk...@chromium.org> wrote:

3. Add the 'error' attribute to ErrorEvent, and pass it into the 'window.onerror' handler as the 5th parameter.


would be the best thing ever. We're currently running in strict mode (so no caller information available), and wrapping all entry points in try/catch to ensure we get stacks for all errors is difficult.

A big +1 from me!

Michael

PhistucK

unread,
Jul 25, 2013, 12:22:27 PM7/25/13
to Michael Davidson, Mike West, blink-dev
I am also very supportive of all of these.


PhistucK

Erik Arvidsson

unread,
Jul 25, 2013, 3:06:49 PM7/25/13
to PhistucK, Adam Barth, Michael Davidson, Mike West, blink-dev
LGTM

Is there any chance we can change the property names to be consistent?
--
erik

Christophe Dumez

unread,
Jul 25, 2013, 3:10:30 PM7/25/13
to Erik Arvidsson, PhistucK, Adam Barth, Michael Davidson, Mike West, blink-dev

On Thursday 25 July 2013 at 22:06, Erik Arvidsson wrote:

LGTM

Is there any chance we can change the property names to be consistent?

Let’s see, the following bug was filed:

Kr,
-- 
Christophe Dumez

Christophe Dumez

unread,
Jul 26, 2013, 2:14:56 AM7/26/13
to Erik Arvidsson, PhistucK, Adam Barth, Michael Davidson, Mike West, blink-dev
Hi,

Good news, ‘column’ was just renamed to ‘colno’ in the specification to match IE10:

Kr,
-- 
Christophe Dumez

Dimitri Glazkov

unread,
Jul 26, 2013, 9:32:37 AM7/26/13
to Christophe Dumez, Erik Arvidsson, PhistucK, Adam Barth, Michael Davidson, Mike West, blink-dev
LGTM.

Adam Barth

unread,
Jul 30, 2013, 12:48:28 PM7/30/13
to Christophe Dumez, Erik Arvidsson, PhistucK, Michael Davidson, Mike West, blink-dev
On Thu, Jul 25, 2013 at 11:14 PM, Christophe Dumez <dch...@gmail.com> wrote:
Good news, ‘column’ was just renamed to ‘colno’ in the specification to match IE10:

^^^ That's great.  LGTM.

Jochen Eisinger

unread,
Jul 30, 2013, 12:58:42 PM7/30/13
to Adam Barth, Christophe Dumez, Erik Arvidsson, PhistucK, Michael Davidson, Mike West, blink-dev
LGTM
Reply all
Reply to author
Forward
0 new messages