Page MenuHomePhabricator

Create error logging JS module
Open, NormalPublic


Create an mw.errorLog ResourceLoader module in core. The module should have two entry points:

  • logException takes an exception (and optionally additional data) and reports it to the server.
  • logError takes the same arguments as window.onerror and reports them to the server.

Reporting to the server means composing an error object, and sending it via one of these methods:

  • AJAX request to a configurable endpoint
  • GET parameters of a HTTP request to a configurable endpoint (with a fake image, the same way EventLogging does it)
  • configurable callback function
  • log to console

The method and endpoint/callback should be configurable in LocalSettings. There should also be a configuration variable to automatically call the logger from window.onerror.

At this point, it is OK to assume exceptions and onerror events behave the way they do in modern browsers. Unexpected input should not cause a new error, though.

The entry points should return an error id that can help the user to find or report the error. At this point it is fine to just return a random token (eventually this will be something like the hash of the error location). The error id should be reported home along with all other error data.

Document the concept, functionality and configuration settings on

Event Timeline

Tgr created this task.Sep 28 2014, 6:34 PM
Tgr raised the priority of this task from to 0.
Tgr updated the task description. (Show Details)
Tgr added a project: Architecture.
Tgr changed Security from none to None.
Tgr added a subscriber: Tgr.
Restricted Application assigned this task to Qgil-test. · View Herald TranscriptSep 28 2014, 6:34 PM
Tgr claimed this task.Sep 28 2014, 6:35 PM
Tgr raised the priority of this task from 0 to Unbreak Now!.
Tgr lowered the priority of this task from Unbreak Now! to Normal.
Tgr updated the task description. (Show Details)Sep 28 2014, 8:21 PM
Tgr updated the task description. (Show Details)Sep 29 2014, 9:39 AM
Tgr updated the task description. (Show Details)Sep 29 2014, 2:54 PM
Tgr updated the task description. (Show Details)Sep 30 2014, 1:50 PM
Tgr updated the task description. (Show Details)Oct 1 2014, 10:06 AM
Tgr removed Tgr as the assignee of this task.Jan 30 2015, 2:38 AM
Jdforrester-WMF moved this task from Untriaged to Backlog on the Multimedia board.Sep 4 2015, 6:41 PM
Restricted Application added subscribers: Matanya, Aklapper. · View Herald TranscriptSep 4 2015, 6:41 PM

to push forward on Sentry, we have to sort of do this and T500 at the same time. So let's start here. Two options:

  • new extension, something like ClientErrorLogging, very similar in code architecture to how EventLogging works
  • add a new independent module to EventLogging, something like ext.eventLogging.errorLogging


Tgr added a subscriber: phuedx.Apr 12 2019, 5:41 AM

A very minimal error handler has been added to core: mediawiki.errorLogger.js. It doesn't do anything beyond pushing exceptions on an mw.track channel.
The rest was written as Extension:Sentry which uses the Sentry client library to report those exceptions. This was done four years ago so the frontend code is very outdated. We might or might not want to use the Sentry library anyway - it can canonicalize stack traces which is nice, but initially we don't need stack traces (and can't have useful traces anyway due to lack of source map support in ResourceLoader), and it is fairly large. @phuedx or the Reading Web team are probably better people to coordinate with on this.

Ok, thanks very much Gergo, looks like Sam set up a meeting for next week, we'll take it from there. Once I understand better how I can help, we should clean up these phab tasks.