node.js - NodeJS 和 CallStack 大小保护
问题描述
NodeJS 是否能够查看或设置任何限制(在运行时或通过 CLI 标志?)调用堆栈的大小?
如果我创建一个看起来像这样的程序并运行它
const recurse = (num=0) => {
console.log('level ' + num);
recurse(++num)
}
recurse()
Node 最终会因为这个错误退出程序
//...
level 12021
_stream_readable.js:872
Readable.prototype.removeListener = function(ev, fn) {
^
RangeError: Maximum call stack size exceeded
at WriteStream.Readable.removeListener (_stream_readable.js:872:45)
at write (console.js:172:12)
at Console.log (console.js:200:3)
at recurse (/path/to/so.js:2:11)
at recurse (/path/to/so.js:3:3)
at recurse (/path/to/so.js:3:3)
at recurse (/path/to/so.js:3:3)
at recurse (/path/to/so.js:3:3)
at recurse (/path/to/so.js:3:3)
at recurse (/path/to/so.js:3:3)
C02V30M6HTDG:test-express-app astorm$ cat so.js
const recurse = (num=0) => {
console.log('level ' + num);
recurse(++num)
}
recurse()
它救助的水平/深度各不相同(通常在 10,000 - 13,000 范围内)。此错误消息告诉我调用堆栈大小(不是深度)是问题所在,但不清楚这里的大小(我假设节点数据结构大小是内部的)。
我想知道的是——节点是否允许我
- 查看/设置此调用堆栈保护启动的大小
- 查看/设置调用堆栈的深度限制。
我没有要解决的任何特定问题,我只是想了解 NodeJS 与我使用过的其他语言相比,给了我多少控制权。
解决方案
推荐阅读
- reactjs - React 是否会发送其整个公共目录内容?
- php - 我可以使用 swift 将 html 类型设置为邮件主题吗?
- kibana - 将时间范围从 Kibana 变为无痛脚本领域
- python - 如何将 Django-Filter 与 Django-Taggit 一起使用(按标签过滤帖子)?
- python - Python BeautifulSoup 通过实时价格循环
- c# - View Cube - 用户指定的标签
- java - Python 中 [V, D] = eig(A, B) 的等效代码是什么?广义特征值问题
- swift - 在奥特莱斯系列中选择一项 - 迅速
- python - 在for循环中使用生成器时,只产生一项
- drupal - 查看过滤器标准 - 和/或组过滤器的条件 - Drupal 8