d-_*_*_-b 12 javascript v8 node.js promise
我正在尝试从 Node.js 中的 Promise 中找到未处理拒绝的来源
我尝试使用该--async-stack-traces选项升级到 Node 12 版,并使用以下方法监听它们:
process.on("unhandledRejection",( reason, promise ) => {
console.log(reason);
console.log(promise);
});
Run Code Online (Sandbox Code Playgroud)
但是我仍然没有看到任何有用的堆栈跟踪来帮助我找到罪魁祸首!
UnhandledPromiseRejectionWarning: TypeError: Chaining cycle detected for promise #<Promise>
at process._tickCallback (internal/process/next_tick.js:68:7)
(node:89675) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 11)
Run Code Online (Sandbox Code Playgroud)
运行节点 v10.10.0
感谢所有的建议。我再次尝试升级到最新的 Node 12.14.1,终于能够让它显示堆栈跟踪:
我node --async-stack-traces myScript.js结合使用:
process.on('unhandledRejection', (reason, p) => {
console.log(reason);
});
Run Code Online (Sandbox Code Playgroud)
它追踪到了错误。
| 归档时间: |
|
| 查看次数: |
773 次 |
| 最近记录: |