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

后端 未结 4 1907
花落未央
花落未央 2020-12-07 11:11

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         


        
4条回答
  •  难免孤独
    2020-12-07 11:46

    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

提交回复
热议问题