简体   繁体   English

如何增加 Google Chrome 开发者工具(或 Firefox)中调用堆栈条目的数量?

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

How to increase number of Call Stack entries in Google Chrome Developer Tools (or Firefox Firebug)?如何增加 Google Chrome 开发者工具(或 Firefox Firebug)中调用堆栈条目的数量? I am getting a Javascript error in a third party control's Javascript.我在第三方控件的 Javascript 中遇到 Javascript 错误。 All the calls in the Call Stack window do not belong to my own code. Call Stack 窗口中的所有调用都不属于我自己的代码。 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.调用堆栈不够大,无法显示我自己的代码中的某些内容。

Chrome solution镀铬解决方案

https://v8.dev/docs/stack-trace-api https://v8.dev/docs/stack-trace-api

can set via commandline on startup --js-flags="--stack-trace-limit <value>"可以在启动时通过命令行设置--js-flags="--stack-trace-limit <value>"

or at runtime at loading a page: Error.stackTraceLimit=undefined //unlimited stack trace或在运行时加载页面: Error.stackTraceLimit=undefined //unlimited stack trace

In Chrome (also in node), you can type this in the js console:在 Chrome(也在 node 中)中,您可以在 js 控制台中输入:

Error.stackTraceLimit = Infinity;

Alternatively see this page for Chrome command line flags: https://v8.dev/docs/stack-trace-api (need to restart Chrome):或者,请参阅此页面以获取 Chrome 命令行标志: https : //v8.dev/docs/stack-trace-api (需要重新启动 Chrome):

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

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 )超时( window.setTimeout
  • an interval ( window.setInterval )一个间隔( window.setInterval
  • some script loading after page has loaded (possibly iframe)页面加载后加载一些脚本(可能是 iframe)

*) Of course, technically there certainly is some limit, but I gues it's practically irrelevant. *) 当然,从技术上讲肯定有一些限制,但我认为这实际上无关紧要。 Probably longint or something.可能是longint什么的。


edit: From Firebug source code :编辑:来自Firebug 源代码

    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.因此 Firebug 将始终显示调用堆栈的前 50 项和后 50 项(“帧”)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM