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

Everything is broken, and I don't know why.

Everything is broken, and I don't know why.

JSConf US
May 28th 2014

Video: https://www.youtube.com/watch?v=e4eE5VeO1_o

Matt Robenolt

May 28, 2014
Tweet

More Decks by Matt Robenolt

Other Decks in Technology

Transcript

  1. JSConf US May 28th 2014 Matt Robenolt Everything is broken,

    and I don’t know why. Help! Help! Help! Help! Help!
  2. If an exception happens in production and nobody sees the

    Chrome debug console, did it really happen?
  3. If the script is on another domain, it’s subject to

    CORS. Meaning… “Script error.”
  4. A stack trace is a record of function calls until

    now within the current call stack.
  5. Error: lol at repl:1:7 at REPLServer.self.eval (repl.js:110:21) at repl.js:249:20 at

    REPLServer.self.eval (repl.js:122:7) at Interface.<anonymous> (repl.js:239:12) at Interface.EventEmitter.emit (events.js:95:17) at Interface._onLine (readline.js:202:10) at Interface._line (readline.js:531:8) at Interface._ttyWrite (readline.js:760:14) at ReadStream.onkeypress (readline.js:99:10)
  6. Error: lol at repl:1:7 at REPLServer.self.eval (repl.js:110:21) at repl.js:249:20 at

    REPLServer.self.eval (repl.js:122:7) at Interface.<anonymous> (repl.js:239:12) at Interface.EventEmitter.emit (events.js:95:17) at Interface._onLine (readline.js:202:10) at Interface._line (readline.js:531:8) at Interface._ttyWrite (readline.js:760:14) at ReadStream.onkeypress (readline.js:99:10) name
  7. Error: lol at repl:1:7 at REPLServer.self.eval (repl.js:110:21) at repl.js:249:20 at

    REPLServer.self.eval (repl.js:122:7) at Interface.<anonymous> (repl.js:239:12) at Interface.EventEmitter.emit (events.js:95:17) at Interface._onLine (readline.js:202:10) at Interface._line (readline.js:531:8) at Interface._ttyWrite (readline.js:760:14) at ReadStream.onkeypress (readline.js:99:10) message
  8. Error: lol at repl:1:7 at REPLServer.self.eval (repl.js:110:21) at repl.js:249:20 at

    REPLServer.self.eval (repl.js:122:7) at Interface.<anonymous> (repl.js:239:12) at Interface.EventEmitter.emit (events.js:95:17) at Interface._onLine (readline.js:202:10) at Interface._line (readline.js:531:8) at Interface._ttyWrite (readline.js:760:14) at ReadStream.onkeypress (readline.js:99:10) stack trace
  9. Error: lol at repl:1:7 at REPLServer.self.eval (repl.js:110:21) at repl.js:249:20 at

    REPLServer.self.eval (repl.js:122:7) at Interface.<anonymous> (repl.js:239:12) at Interface.EventEmitter.emit (events.js:95:17) at Interface._onLine (readline.js:202:10) at Interface._line (readline.js:531:8) at Interface._ttyWrite (readline.js:760:14) at ReadStream.onkeypress (readline.js:99:10) frame
  10. Error: lol at repl:1:7 at REPLServer.self.eval (repl.js:110:21) at repl.js:249:20 at

    REPLServer.self.eval (repl.js:122:7) at Interface.<anonymous> (repl.js:239:12) at Interface.EventEmitter.emit (events.js:95:17) at Interface._onLine (readline.js:202:10) at Interface._line (readline.js:531:8) at Interface._ttyWrite (readline.js:760:14) at ReadStream.onkeypress (readline.js:99:10) caller
  11. Error: lol at repl:1:7 at REPLServer.self.eval (repl.js:110:21) at repl.js:249:20 at

    REPLServer.self.eval (repl.js:122:7) at Interface.<anonymous> (repl.js:239:12) at Interface.EventEmitter.emit (events.js:95:17) at Interface._onLine (readline.js:202:10) at Interface._line (readline.js:531:8) at Interface._ttyWrite (readline.js:760:14) at ReadStream.onkeypress (readline.js:99:10) source
  12. Error: lol at repl:1:7 at REPLServer.self.eval (repl.js:110:21) at repl.js:249:20 at

    REPLServer.self.eval (repl.js:122:7) at Interface.<anonymous> (repl.js:239:12) at Interface.EventEmitter.emit (events.js:95:17) at Interface._onLine (readline.js:202:10) at Interface._line (readline.js:531:8) at Interface._ttyWrite (readline.js:760:14) at ReadStream.onkeypress (readline.js:99:10) line number
  13. Error: lol at repl:1:7 at REPLServer.self.eval (repl.js:110:21) at repl.js:249:20 at

    REPLServer.self.eval (repl.js:122:7) at Interface.<anonymous> (repl.js:239:12) at Interface.EventEmitter.emit (events.js:95:17) at Interface._onLine (readline.js:202:10) at Interface._line (readline.js:531:8) at Interface._ttyWrite (readline.js:760:14) at ReadStream.onkeypress (readline.js:99:10) column number
  14. // awesome.js (function() { ! var things = [ {foo:

    'bar'} ]; ! function showThing(index) { console.log(things[index].foo); } ! showThing(1); ! })();
  15. $ node awesome.js ! /jsconf/awesome.js:9 console.log(things[index].foo); ^ TypeError: Cannot read

    property 'foo' of undefined at showThing (/jsconf/awesome.js:9:30) at /jsconf/awesome.js:12:3 at Object.<anonymous> (/jsconf/awesome.js:14:2)
  16. Safari ! TypeError: 'undefined' is not an object (evaluating ‘things[index].foo')

    ! showThing@http://localhost:8000/awesome.js:9:30 http://localhost:8000/awesome.js:12:16 global code@http://localhost:8000/awesome.js:14:2
  17. $ node awesome.min.js ! /jsconf/awesome.min.js:1 o=[{foo:"bar"}];function n(n){console.log(o[n].foo)}n(1) ^ TypeError: Cannot

    read property 'foo' of undefined at n (/jsconf/awesome.min.js:1:125) at /jsconf/awesome.min.js:1:131 at Object.<anonymous> (/jsconf/awesome.min.js:1:137)
  18. We can tell V8 how to transform raw CallSite objects

    into the Error.prototype.stack property.
  19. try { doStuff() } catch(error) { // log it first

    logError(error) throw error; }
  20. try { doStuff() } catch(error) { // log it first

    logError(error) throw error; }
  21. You must predict when your code is going to break.

    If we don’t, it bubbles up to window.onerror.
  22. function wrap(func) { function wrapped() { try { return func.apply(this,

    arguments) } catch(e) { logError(e) throw e } } return wrapped }
  23. wrap(function() { ! var things = [ {foo: 'bar'} ];

    ! function showThing(index) { console.log(things[index].foo); } ! showThing(1); ! })();
  24. Sentry will fetch your source maps and give you a

    nice clean view of your error.