gpt4 book ai didi

javascript - 查找未处理的 promise 拒绝 : TypeError: Chaining cycle detected for promise 的来源

转载 作者:行者123 更新时间:2023-12-01 14:51:19 24 4
gpt4 key购买 nike

我正在尝试从 Node.js 中的 Promise 中找到未处理拒绝的来源

我尝试使用 --async-stack-traces 升级到 Node 版本 12选项,并使用以下方法监听它们:

process.on("unhandledRejection",( reason, promise ) => {
console.log(reason);
console.log(promise);
});

但是我仍然没有看到任何有用的堆栈跟踪来帮助我找到罪魁祸首!
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)

运行 Node v10.10.0

最佳答案

如果你错过了一个有用的堆栈跟踪,你可以通过在你的处理程序中重新抛出你的错误来让 Node 创建一个新的,如下所示:

process.on('unhandledRejection', (reason, p) => { throw reason });

这样,您应该能够找到罪魁祸首。

关于javascript - 查找未处理的 promise 拒绝 : TypeError: Chaining cycle detected for promise 的来源,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59286837/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com