Node.js堆栈错误中有10行以上?
有没有办法在node.js堆栈错误中获得10行以上?
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);
}
节目:
$ 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)
有没有办法接到10个以上的电话?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
最简单的解决方案是启动您的代码以下:
如果您想查看跨越settimeout/setInterval呼叫的堆栈跟踪,那么更复杂的 https://github.com/mattinsler/longjohn 将是必经之路。
Easiest solution for that is to start your code with following:
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.
您可以将stack跟踪限制作为命令行参数传递到
node
:node -stack-trace-limit = 1000 debug.js
//默认10btw,另一件事听起来不太可能发生,但是只是浪费了几个小时的调试时间,是堆栈尺寸(默认为492 kb)。如果堆栈耗尽,则可能会有非常不知情的错误(
rangeRor
而没有任何其他信息)。 您可以使用:node -stack-size = 1024 debug.js
//默认492在回调到callback-to-callback-to-callback的世界中连锁店,如果没有在此过程中编写该程序,则实际上很容易超过大输入尺寸的堆栈尺寸。
要查看所有与堆栈相关的选项:
node -v8-options | GREP -B0 -A1堆栈
You can pass stack trace limit as a command line param to
node
:node --stack-trace-limit=1000 debug.js
// default 10BTW, 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 492In 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
您可以在
node_options
变量中设置跟踪限制:You can set the trace limit within
NODE_OPTIONS
variable:使用 https://github.com/tlrobinson/long-stack-stack-traces 模块。
Use the https://github.com/tlrobinson/long-stack-traces module.
Also you can use built-in debugger, which opens familiar Google Chrome's dev-tools debugger 。它会停止任何错误,您可以浏览整个堆栈。只是运行:
Also you can use built-in debugger, which opens familiar Google Chrome's dev-tools debugger. It stops on any error and you can browse the whole stack. Just run: