Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IE11 Console: Increase stack trace depth

In Chrome, you can increase the stack trace depth by setting a flag at runtime (using --js-flags="--stack-trace-limit <value>"), or through the console (using Error.stackTraceLimit), explained here: https://code.google.com/p/v8/wiki/JavaScriptStackTraceApi

This is also possible in Firebug, from what I understand, although I'm not as familiar with the intricacies of that tool.

Is there any provision for this in IE11? I'm dealing with an IE-specific issue, and the stack trace doesn't shed any light beyond my library's code (AngularJS). Increasing the stack trace depth would likely help me here.

Thanks!

like image 584
jedd.ahyoung Avatar asked Dec 27 '13 21:12

jedd.ahyoung


2 Answers

It appears that no documented Command Line Option exists that would offer this control. You can, however, increase the stack trace in Internet Explorer much like you would other popular browsers:

Error.stackTraceLimit = 20; // The default is 10

Internet Explorer has supported this property on the Error constructor since version 10. It will not work in versions prior to that. In 2012 the IEBlog demonstrated some sample use of this property, as well as use of Error.stack.

There doesn't appear to be any way to persist this setting for all page requests. The only option I could suggest here would be to setup a proxy that adds this to all server responses. Naturally I would encourage Fiddler for this.

Like other browsers, Internet Explorer 11 supports console.trace. So you need not wait for an error to get your stack trace. You can invoke it arbitrarily at any time.

One last feature to look at would be profiling. You can control profiling sessions via console.profile and console.profileEnd (both of which are fairly standard) if you wish to capture only a specific slice of your applications lifecycle.

like image 104
Sampson Avatar answered Dec 31 '22 14:12

Sampson


I found the answer to this by simply playing around in the console - I knew there was an Error object. As it turns out, the Error object in IE11 supports the same stackTraceLimit property that Chrome and Firebug do (I guess they standardized it, finally). This can be set in the console, similar to Google Chrome (example: Error.stackTraceLimit = 30) and it will persist from the time you set it until the next navigation event - going back, forward, anywhere else, or refreshing the page.

The default for the stackTraceLimit is 10.

I needed to set this when the page loaded to debug an error, and so I was able to set an early breakpoint and manually set Error.stackTraceLimit. I haven't found a way to make this persist across navigation yet, and I don't know if there's a startup flag or anything to set it in a more permanent fashion. (I'd postulate that there's a registry entry somewhere.)

I hope this helps someone else who comes across this issue. Of note, the new IE11 tools will autocomplete properties of a native object, which is actually pretty nice, so you can quickly see what other properties and methods the Error object has. (This is actually how I found the property in question.)

like image 25
jedd.ahyoung Avatar answered Dec 31 '22 14:12

jedd.ahyoung