Julien Genestoux Julien Genestoux - 4 months ago 11
Node.js Question

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?

Answer

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.