How to increase number of Call Stack entries in Google Chrome Developer Tools (or Firefox)?

那年仲夏 提交于 2019-11-30 10:25:45

问题


How to increase number of Call Stack entries in Google Chrome Developer Tools (or Firefox Firebug)? I am getting a Javascript error in a third party control's Javascript. All the calls in the Call Stack window do not belong to my own code. I want to know which line in my code triggered the sequence of events. The Call Stack is not large enough to display something from my own code.


回答1:


Chrome solution

https://github.com/v8/v8/wiki/Stack%20Trace%20API

can set via commandline on startup --js-flags="--stack-trace-limit <value>"

or at runtime at loading a page: Error.stackTraceLimit=undefined //unlimited stack trace




回答2:


In Chrome (also in node), you can type this in the js console:

Error.stackTraceLimit = Infinity;

Alternatively see this page for Chrome command line flags: https://v8.dev/docs/stack-trace-api (need to restart Chrome):

$ google-chrome --js-flags="--stack-trace-limit 10000"



回答3:


I don't think there's a limit on call stack size*). Usually a stack trace that seems to come out of nowhere results from either

  • an event listener
  • a timeout (window.setTimeout)
  • an interval (window.setInterval)
  • some script loading after page has loaded (possibly iframe)

*) Of course, technically there certainly is some limit, but I gues it's practically irrelevant. Probably longint or something.


edit: From Firebug source code:

    if (trace.frames.length > 100)  // TODO in the loop above
    {
        var originalLength = trace.frames.length;
        trace.frames.splice(50, originalLength - 100);
        var excuse = "(eliding "+(originalLength - 100)+" frames)";

        trace.frames[50] = new StackFrame.StackFrame({href: excuse}, 0, excuse,
            [], null, null, context);
     }

So Firebug will always show the first 50 and the last 50 items ("frames") of the call stack.



来源:https://stackoverflow.com/questions/9931444/how-to-increase-number-of-call-stack-entries-in-google-chrome-developer-tools-o

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!