More than 10 lines in a node.js stack error?

Is there a way to get more than 10 lines in a node.js stack error?

function a() { dieInHell(); }
function b() { a(); }
function c() { b(); }
function d() { c(); }
function e() { d(); }
function f() { e(); }
function g() { f(); }
function h() { g(); }
function i() { h(); }
function j() { i(); }
function k() { j(); }
function l() { k(); }
function m() { l(); }
function n() { m(); }
function o() { n(); }
function p() { o(); }
function q() { p(); }

try {
    q();
}
catch(e) {
    console.log(e.stack);
}

shows :

$ node debug.js 
ReferenceError: dieInHell is not defined
    at a (/Users/julien/tmp/debug.js:2:5)
    at b (/Users/julien/tmp/debug.js:6:5)
    at c (/Users/julien/tmp/debug.js:10:5)
    at d (/Users/julien/tmp/debug.js:14:5)
    at e (/Users/julien/tmp/debug.js:18:5)
    at f (/Users/julien/tmp/debug.js:22:5)
    at g (/Users/julien/tmp/debug.js:26:5)
    at h (/Users/julien/tmp/debug.js:30:5)
    at i (/Users/julien/tmp/debug.js:34:5)
    at j (/Users/julien/tmp/debug.js:38:5)

Is there a way to get more than 10 calls?


Easiest solution for that is to start your code with following:

Error.stackTraceLimit = Infinity;

If you'd like to see stack trace that spans over setTimeout/setInterval calls, then more sophisticated https://github.com/mattinsler/longjohn would be the way to go.


You can pass stack trace limit as a command line param to node:

node --stack-trace-limit=1000 debug.js // default 10

BTW, another thing which sounds unlikely to happen, but just wasted a few hours of my time for debugging, is the stack size (which defaults to 492 kB). You can have very uninformative errors if the stack is exhausted (RangeError without any additional info). You can increase the stack size with:

node --stack-size=1024 debug.js // default 492

In the world of callback-to-callback-to-callback chainings, it's in fact very easy to exceed the stack size for big input sizes, if the program is not written in this in mind.

To see all stack-related options:

node --v8-options | grep -B0 -A1 stack


Use the https://github.com/tlrobinson/long-stack-traces module.