[CLJS-985] ex-info loses stack information Created: 20/Jan/15 Updated: 02/Jul/15 Resolved: 23/Jan/15
Native js Error keeps stacktrace:
But ex-info does not:
Problem is that ex-info inherits stack property from prototype which is instantiated at script load time here:
Problem is that Chrome has setter on stack property, and it only allows for this property to be set inside a constructor functions.
Proposed fix creates new Error each time ex-info is called and sets ExceptionInfo.prototype to newly created error. This way new ExceptionInfo instance will inherit stack from newly created Error with correct stack.
This patch has been tested in Chrome 39 Mac, Safari 8 Mac, Firefox 35 Mac and IE 10 Win. Here's test code I used:
Note that current implementation reports line number and overall stacktrace from cljs.core file where Error prototype is created in current implementation.
|Comment by Nikita Prokopov [ 20/Jan/15 2:48 PM ]|
Ok, this is crazy, but this seems to solve the issue:
Basically we change prototype before creating each object.
I guess high performance is not needed from ex-info, so this solution is somewhat okay-ish? Should I make a patch from it?
|Comment by David Nolen [ 20/Jan/15 2:55 PM ]|
It would be nice to get confirmation from others that this works under the major browser - Safari, Firefox, Chrome, and modern IE.
|Comment by Nikita Prokopov [ 20/Jan/15 3:12 PM ]|
I can confirm Firefox 34, Firefox 35, Safari 8.0.2 and Chrome 39 (all Mac) for now
|Comment by Nikita Prokopov [ 22/Jan/15 3:50 AM ]|
David, I updated issue, added patch, test code and test results (including IE). There’s no unit test on this because stack traces are very engine-specific. Please take a look
|Comment by David Nolen [ 22/Jan/15 2:24 PM ]|
Nikita, thanks for the update will check it out.
|Comment by David Nolen [ 23/Jan/15 6:13 PM ]|
|Comment by Aleksey Kladov [ 01/Jul/15 7:19 PM ]|
Looks like it should be reopened because of this commit
js/Error is constructed with empty message on this line https://github.com/clojure/clojurescript/commit/de130a335bd761d580d04dadb8a5a43d3c0a35b4#diff-a98a037c6c098dd3707e861df3c2f5acR9197
So, when stack is assigned here
I guess that the fix will be to change `(let [e (js/Error.)]` to `(let [e (js/Error. message)]`
|Comment by David Nolen [ 02/Jul/15 5:59 PM ]|
fixed in master