Upgrade to Pro — share decks privately, control downloads, hide ads and more …

JavaScript Error Reporting (and Why We Can't Ha...

JavaScript Error Reporting (and Why We Can't Have Nice Things)

JSConf.uy 2016

benvinegar

April 15, 2016
Tweet

More Decks by benvinegar

Other Decks in Programming

Transcript

  1. Users • Email • Complaints on social media • Bricks

    through your office window lol i can’t believe how broken
 this app is let’s shame them on the internet
  2. Server Error Logs • Server exceptions barfed to a text

    file • Apache: error.log • Commercial logging tools (Splunk, Loggly)
  3. Graphs / Monitoring • Look for spikes / drops when

    deploying
 • You must define these metrics • Looks great on TVs hung in your office
  4. Developer Console • Chrome DevTools, Safari Web Inspector, etc. •

    Console, debugger, element inspector, network inspector, more • but … needs to be open to see it
  5. try/catch (pre-2000) • No filenames, no stack trace, no line

    numbers • Does not catch syntax errors • Async callbacks means you have to write try/ catch everywhere
  6. Error: lol
 at repl:1:
 at REPLServer.defaultEval (repl.js:164:27)
 at bound (domain.js:250:14)


    at REPLServer.runBound [as eval] (domain.js:263:12)
 at REPLServer.<anonymous> (repl.js:392:12)
 at emitOne (events.js:82:20)
 at REPLServer.emit (events.js:169:7)
 at REPLServer.Interface._onLine (readline.js:210:10)
 at REPLServer.Interface._line (readline.js:546:8)
 at REPLServer.Interface._ttyWrite (readline.js:823:14) throw new Error(‘lol’)
  7. Error: lol
 at repl:1:
 at REPLServer.defaultEval (repl.js:164:27)
 at bound (domain.js:250:14)


    at REPLServer.runBound [as eval] (domain.js:263:12)
 at REPLServer.<anonymous> (repl.js:392:12)
 at emitOne (events.js:82:20)
 at REPLServer.emit (events.js:169:7)
 at REPLServer.Interface._onLine (readline.js:210:10)
 at REPLServer.Interface._line (readline.js:546:8)
 at REPLServer.Interface._ttyWrite (readline.js:823:14) Name
  8. Error: lol
 at repl:1:
 at REPLServer.defaultEval (repl.js:164:27)
 at bound (domain.js:250:14)


    at REPLServer.runBound [as eval] (domain.js:263:12)
 at REPLServer.<anonymous> (repl.js:392:12)
 at emitOne (events.js:82:20)
 at REPLServer.emit (events.js:169:7)
 at REPLServer.Interface._onLine (readline.js:210:10)
 at REPLServer.Interface._line (readline.js:546:8)
 at REPLServer.Interface._ttyWrite (readline.js:823:14) Message
  9. Error: lol
 at repl:1:
 at REPLServer.defaultEval (repl.js:164:27)
 at bound (domain.js:250:14)


    at REPLServer.runBound [as eval] (domain.js:263:12)
 at REPLServer.<anonymous> (repl.js:392:12)
 at emitOne (events.js:82:20)
 at REPLServer.emit (events.js:169:7)
 at REPLServer.Interface._onLine (readline.js:210:10)
 at REPLServer.Interface._line (readline.js:546:8)
 at REPLServer.Interface._ttyWrite (readline.js:823:14) Stack
  10. Error: lol
 at repl:1:
 at REPLServer.defaultEval (repl.js:164:27)
 at bound (domain.js:250:14)


    at REPLServer.runBound [as eval] (domain.js:263:12)
 at REPLServer.<anonymous> (repl.js:392:12)
 at emitOne (events.js:82:20)
 at REPLServer.emit (events.js:169:7)
 at REPLServer.Interface._onLine (readline.js:210:10)
 at REPLServer.Interface._line (readline.js:546:8)
 at REPLServer.Interface._ttyWrite (readline.js:823:14) Frame
  11. Error: lol
 at repl:1:
 at REPLServer.defaultEval (repl.js:164:27)
 at bound (domain.js:250:14)


    at REPLServer.runBound [as eval] (domain.js:263:12)
 at REPLServer.<anonymous> (repl.js:392:12)
 at emitOne (events.js:82:20)
 at REPLServer.emit (events.js:169:7)
 at REPLServer.Interface._onLine (readline.js:210:10)
 at REPLServer.Interface._line (readline.js:546:8)
 at REPLServer.Interface._ttyWrite (readline.js:823:14) Caller
  12. Error: lol
 at repl:1:
 at REPLServer.defaultEval (repl.js:164:27)
 at bound (domain.js:250:14)


    at REPLServer.runBound [as eval] (domain.js:263:12)
 at REPLServer.<anonymous> (repl.js:392:12)
 at emitOne (events.js:82:20)
 at REPLServer.emit (events.js:169:7)
 at REPLServer.Interface._onLine (readline.js:210:10)
 at REPLServer.Interface._line (readline.js:546:8)
 at REPLServer.Interface._ttyWrite (readline.js:823:14) Source, Line Number, Column Number
  13. > new Error('lol').stack 'Error: lol\n at repl:1:1\n at REPLServer.defaultEval (repl.js:164:27)\n

    at bound (domain.js:250:14)\n at REPLServer.runBound [as eval] (domain.js: 263:12)\n at REPLServer.<anonymous> (repl.js:392:12)\n at emitOne (events.js:82:20)\n at REPLServer.emit (events.js:169:7)\n at REPLServer.Interface._onLine (readline.js: 210:10)\n at REPLServer.Interface._line (readline.js:546:8)\n at REPLServer.Interface._ttyWrite (readline.js:823:14)'
  14. Chrome 49 identifies bar as an object
 property of MyClass

    cannot identify functions
 assigned to variables inconsistent parens
  15. Firefox 44 different line number? identifies bar as a prototype


    method of MyClass has variable name of
 anonymous function 
 (what’s ‘<‘?)
  16. Safari 9 does not identify bar as a
 property of

    MyClass identifies code executed 
 in global scope more line number
 changes
  17. window.onerror compatibility Line Column Error (Stack) Chrome ✓ ✓ ✓

    Firefox ✓ ✓ ✓ Safari 9 ✓ ✓ Edge ✓ ✓ IE 11+ ✓ ✓ ✓ IE 10 ✓ ✓ IE 8, 9 ✓
  18. Easy to get a lot of value with window.onerror +

    libraries + reporting endpoint.
  19. More stuff • Thanks to Matt Robenolt and the Sentry

    team for helping me with these slides • Stacktrace.js: https://stacktracejs.com • TraceKit: https://github.com/csnover/tracekit • me: @bentlegen • Sentry plug: https://getsentry.com