eriwen/javascript-stacktrace — pull request #34 by hlascelles (2012-02-07 13:00:13+00:00)
Title: Stacktrace crash on eval of anonymous function

I'm seeing an exception when trying to create a stacktrace for tracing purposes.

The actual window level error is reported as this:

Uncaught TypeError: Cannot read property '1' of null
URL: http://localhost:4000/javascripts/stacktrace.js
Line: 349

So the call "m[1]" is failing in stacktrace.js

Here is the output for the "ref" object at that time

Array[2]
0: "{anonymous}()@eval at buildTmplFn (http://localhost:4000/javascripts/jquery/jquery.tmpl.js:317:10)"
1: "eval at buildTmplFn (http://localhost:4000/javascripts/jquery/jquery.tmpl.js:317:10)"
index: 0
input: "{anonymous}()@eval at buildTmplFn (http://localhost:4000/javascripts/jquery/jquery.tmpl.js:317:10)"
length: 2
__proto__: Array[0]

The jquery file used is this one, http://cloud.github.com/downloads/SteveSanderson/knockout/jquery.tmpl.js

It's quite a dense function to look into, but suffice to say stacktrace.js fails to evaluate "m" at line 349 of stacktrace.js as anything other than null. This causes the stacktrace construction to blow out.

This simple pull request change evades the issue. It happens rarely (but reliably) under certain uses of jquery templating.

Not the best pull request summary I've ever done, sorry, but I assure you the problem and solution are genuine.

Let me know if there is any more logging you need.

H