47

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.

2
  • If you put a breakpoint in the earliest call, can you see what came before it? Commented Mar 29, 2012 at 18:45
  • For testing you can try to up the js stack size: code.google.com/p/v8/issues/detail?id=1631 Commented Aug 3, 2012 at 8:12

3 Answers 3

33

Chrome solution

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

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

or at runtime at loading a page:

Error.stackTraceLimit = Infinity //unlimited stack trace 

NOTE that this no longer works:

Error.stackTraceLimit = undefined // no stack trace at all! (same as 0) 
Sign up to request clarification or add additional context in comments.

9 Comments

Can you please show the full command? I tried open -a Google\ Chrome --args --js-flags="--stack-trace-limit 50" but the stack trace still stops at 10
if you open chrome dev console you can just type '''Error.stackTraceLimit''' and it will show you the current value. you can then modify it as you wish.
such as Error.stackTraceLimit=50
Setting the Error.stackTraceLim‌​it doesn't work anymore.
Setting the Error.stackTraceLim‌​it property works on Chrome 60. Running on Ubuntu.
|
19

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" 

Comments

-2

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.

1 Comment

You are wrong. There is a maximum stack size and it is very important. Not for stuff written in an async way - but more e.g. for interpreters. I ran into this problem with Chrome (has a far smaller maximum stack size than Firefox has) when having a Lisp interpreter. Mostly in the end the best thing to do is to change your JavaScript so it runs asynchronously (and to slice the processing via setTimeout). That said - for a third party script I do not really have a good idea how to solve it.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.