javascript - Nodejs MaxListenersExceededWarning 在 aws lambda 中限制了堆栈跟踪
问题描述
我在带有 API-Gateway 的 AWS lambda 中使用 nodejs 8.10。我收到 MaxListenersExceededWarning。process.setMaxListeners(0);
我在 express 应用的 app.js 中尝试过。但仍然存在警告。为了获得更多详细信息,我已将其添加到我的代码中。
process.on('warning', (warning) => {
console.log("[+] Warning ", JSON.stringify(warning));
console.log(warning.name); // Print the warning name
console.log(warning.message); // Print the warning message
console.log(warning.stack); // Print the stack trace
});
但是堆栈和所有内容的信息非常有限。
{
"name": "MaxListenersExceededWarning",
"emitter": {
"fetching": false,
"_events": {
"value": [
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null
]
},
"_eventsCount": 1
},
"type": "value",
"count": 11
}
它没有告诉我具体在哪个地方有错误。另外,这个错误在本地不可用,它只在生产中,所以我不认为有一种方法可以在生产 lambda 中添加 --stack-trace 。
解决方案
推荐阅读
- python - 逐个循环浏览文件夹中的文件
- java - 如何替换 Java 中的 " 字符?
- python - 如何读取位于项目内不同目录中的文件?
- python - 使用 wget 下载 CSV
- javascript - Google Apps 脚本日历服务:分块处理许多事件:如何以编程方式触发下一个函数运行以继续下一个块?
- visual-studio-code - VSCode - 在 Zen 模式下切换导航(Linux Ubuntu)
- python - 如何在 Windows 7 中的 python 3 Jupyter note Book 6.0.3 中创建文件(testfile.txt)
- dart - 无法理解这段代码的最后一部分 - Dart
- python-3.x - 如何将 openpyxl 与 cx_Freeze 一起使用
- java - XPath 解析特定节点