[英]Node not throwing Stack Overflow exception
I'm trying to force a stack overflow with this code: 我正在尝试使用此代码强制堆栈溢出:
// Throws stack overflow exception
var count = 0;
try {
(function curse() {
console.log(count++);
curse();
})();
} catch (e) {
console.log('ERROR');
console.log(e.message);
}
However, when I run it, it prints numbers to the screen and then exits gracefully. 但是,当我运行它时,它会在屏幕上打印数字,然后正常退出。 No exception thrown, I can remove the try-catch
and still no exception is output to the console. 没有引发异常,我可以删除try-catch
,但是仍然没有异常输出到控制台。
Why don't I get an exception message dumped to the console? 为什么我没有将异常消息转储到控制台?
Node version is v0.12.2
, V8 is 3.28.73
. 节点版本是v0.12.2
,V8是3.28.73
。
If you upgrade to the latest node.js (currently v4.1.2), you will probably be able to see the exception message dumped to the console. 如果升级到最新的node.js (当前为v4.1.2),则可能能够看到转储到控制台的异常消息。 This seems to have been a bug in older versions of node.js. 在旧版本的node.js中,这似乎是一个错误。
Also, in your current version of node.js, if you took out the console.log(count++);
另外,在当前版本的node.js中,如果您取出console.log(count++);
statement, you might have been able to see the exception message. 语句,您可能已经能够看到异常消息。 At least, that worked for me with v0.10.26. 至少,对于v0.10.26来说,这对我有用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.