Page MenuHomePhabricator

Catch uncaught exceptions with Sentry
Open, HighPublic1 Story Points

Description

When raven.js is installed, it automatically catches and reports uncaught exceptions via window.onerror. We need a way to catch errors which happen before raven.js is loaded, though - in part because some modules might be loaded before Sentry is, and in debug mode window.onerror is the only way to catch module initialization errors; and in part because we might want to lazy-load raven.js.

We can use the same mw.track mechanism that is used to catch async callback errors; the difficulty is that there is no way to make raven.js not handle window.onerror, so we must be careful not to report errors twice.

Details

Related Gerrit Patches:
mediawiki/extensions/Sentry : masterUse mw.trackUnsubscribe
mediawiki/extensions/Sentry : REL1_23Make Sentry actually lazy-load
mediawiki/extensions/Sentry : masterMake Sentry actually lazy-load
mediawiki/core : masterReport uncaught errors via mw.track
mediawiki/core : masterReport uncaught errors via mw.track
mediawiki/extensions/Sentry : masterCatch uncaught exceptions with Sentry

Event Timeline

Tgr created this task.Feb 7 2015, 1:08 AM
Tgr raised the priority of this task from to Needs Triage.
Tgr updated the task description. (Show Details)
Tgr added a project: Sentry.
Tgr added a subscriber: Tgr.
Restricted Application added a project: Multimedia. · View Herald TranscriptFeb 7 2015, 1:08 AM
Restricted Application added a subscriber: Aklapper. · View Herald Transcript
Tgr moved this task from Untriaged to Next up on the Multimedia board.Feb 7 2015, 1:25 AM
Tgr claimed this task.Feb 10 2015, 6:50 AM
Tgr set Security to None.
Tgr edited a custom field.
Tgr edited a custom field.Feb 18 2015, 1:12 AM

Change 192755 had a related patch set uploaded (by Gergő Tisza):
Report uncaught errors via mw.track

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

Change 192756 had a related patch set uploaded (by Gergő Tisza):
Catch uncaught exceptions with Sentry

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

Change 192756 merged by jenkins-bot:
Catch uncaught exceptions with Sentry

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

Gilles added a subscriber: Gilles.Feb 25 2015, 10:56 AM

I'm rolling these Sentry changesets into the next sprint for testing purposes, because right now I can't even test locally because of T90701

Gilles added a comment.Mar 2 2015, 9:05 AM

I can't seem to make this work, on Firefox. I've added an uncaught exception in Media Viewer when clicking on a specific button, it shows up in the console but not in raven.

Gilles added a comment.Mar 2 2015, 9:12 AM

Maybe this depends on the core changes that are still in review?

Gilles closed this task as Resolved.Mar 2 2015, 9:15 AM

Indeed, soft-depends on https://gerrit.wikimedia.org/r/#/c/192755/

Works fine when that patch is applied to core.

Change 192755 abandoned by Gergő Tisza:
Report uncaught errors via mw.track

Reason:
Abandoning. Will redo in another patch which does not depend on async wrapping as window.onerror-based error logging seems to be an easier win.

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

Change 199557 had a related patch set uploaded (by Gergő Tisza):
Report uncaught errors via mw.track

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

Tgr reopened this task as Open.Mar 25 2015, 10:04 PM

Reopening - removing the default handler is crappy behavior. Sentry should just unregister itself from mw.track instead.
Also, the core patch for this is not merged yet.

Tgr triaged this task as High priority.Mar 25 2015, 10:25 PM

Change 199557 merged by Ori.livneh:
Report uncaught errors via mw.track

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

Change 200277 had a related patch set uploaded (by Gergő Tisza):
Make Sentry actually lazy-load

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

Gilles moved this task from Next up to Untriaged on the Multimedia board.Apr 6 2015, 9:20 AM

Change 200277 merged by jenkins-bot:
Make Sentry actually lazy-load

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

Change 217199 had a related patch set uploaded (by Gergő Tisza):
Make Sentry actually lazy-load

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

Change 217199 merged by jenkins-bot:
Make Sentry actually lazy-load

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

Change 225098 had a related patch set uploaded (by Gergő Tisza):
Use mw.trackUnsubscribe

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

Change 225098 merged by jenkins-bot:
Use mw.trackUnsubscribe

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