相关疑难解决方法(0)

如何在Node.js UnhandledPromiseRejectionWarning中找到未处理的承诺?

来自版本7的Node.js具有async/await语法糖用于处理promises,现在在我的代码中经常出现以下警告:

(node:11057) UnhandledPromiseRejectionWarning: Unhandled promise 
rejection (rejection id: 1): ReferenceError: Error: Can't set headers 
after they are sent.
(node:11057) DeprecationWarning: Unhandled promise rejections are 
deprecated. In the future, promise rejections that are not handled 
will terminate the Node.js process with a non-zero exit code.
Run Code Online (Sandbox Code Playgroud)

不幸的是,没有提到缺少捕获的线.有没有办法找到它而不检查每个try/catch块?

warnings unhandled-exception node.js promise async-await

162
推荐指数
4
解决办法
5万
查看次数