javascript 如何增加 Google Chrome 开发者工具(或 Firefox)中调用堆栈条目的数量?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9931444/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to increase number of Call Stack entries in Google Chrome Developer Tools (or Firefox)?
提问by Tony_Henrich
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.
如何增加 Google Chrome 开发者工具(或 Firefox Firebug)中调用堆栈条目的数量?我在第三方控件的 Javascript 中遇到 Javascript 错误。Call Stack窗口中的所有调用都不属于我自己的代码。我想知道代码中的哪一行触发了事件序列。调用堆栈不够大,无法显示我自己的代码中的某些内容。
回答by JasonS
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
回答by Vlad A Ionescu
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"
回答by user123444555621
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)
- 事件侦听器
- 超时 (
window.setTimeout
) - 一个区间 (
window.setInterval
) - 页面加载后加载一些脚本(可能是 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 项(“帧”)。