Page MenuHomePhabricator

Wrap scripts with exception handling for automatic JS error logging
Open, Stalled, NormalPublic

Description

Automagically wrap scripts in try...catch blocks to improve error reporting:

  • use ResourceLoader::makeLoaderImplementScript() to wrap source code in a try...catch block which passes the exception to the error logger
  • manipulate $, window etc. so that every top-scope call (event handlers, setTimeout etc) can be automatically wrapped in exception handling (probably a fair coverage could be achieved by decorating $.on, $.ready, $.ajax and window.setTimeout/setInterval).
  • create a browser testing suite to make sure no grade-A browser is broken by replacing native functions like setTimout (or ensure others did this already - sinon.js maybe?)

This is an alternative to using window.onerror (and as such an alternative to working around its problems - T508, T512). This might turn out to be too fragile or impractical to be worth doing. (Also, it probably won't work in debug mode when scripts are not minified.)

Event Timeline

Tgr created this task.Sep 29 2014, 11:19 PM
Tgr claimed this task.
Tgr raised the priority of this task from to Normal.
Tgr updated the task description. (Show Details)
Tgr changed Security from none to None.
Tgr added a subscriber: Tgr.
Tgr updated the task description. (Show Details)Sep 30 2014, 3:16 PM
Tgr updated the task description. (Show Details)Oct 1 2014, 9:44 AM
Tgr renamed this task from Wrap scripts with exception handling to Wrap scripts with exception handling for automatic JS error logging.Oct 1 2014, 10:16 AM
Tgr removed Tgr as the assignee of this task.Jan 30 2015, 2:38 AM
gerritbot added a subscriber: gerritbot.

Change 188328 had a related patch set uploaded (by Gergő Tisza):
Wrap asynchronous callbacks with error logging

https://gerrit.wikimedia.org/r/188328

Patch-For-Review

Change 188327 had a related patch set uploaded (by Gergő Tisza):
Allow subscribing to module loading exceptions

https://gerrit.wikimedia.org/r/188327

Patch-For-Review

Change 188327 merged by jenkins-bot:
Allow subscribing to module loading exceptions

https://gerrit.wikimedia.org/r/188327

Change 188328 abandoned by Gergő Tisza:
Wrap asynchronous callbacks with error logging

Reason:
Abandoning, see T92247#1147500. Might be revisited later.

https://gerrit.wikimedia.org/r/188328

Tgr changed the task status from Open to Stalled.Mar 25 2015, 11:42 PM

We are not doing this for the first iteration - might be revisited when we have data on how much it would improve the coverage. See T92247 #1147500.

Jdforrester-WMF moved this task from Untriaged to Backlog on the Multimedia board.Sep 4 2015, 6:41 PM
Restricted Application added a subscriber: Matanya. · View Herald TranscriptSep 4 2015, 6:41 PM