什么是process._tickCallback Node.js错误

时间:2019-01-27 02:10:04

标签: node.js error-handling

我和我的朋友在node.js中从事项目。我们有一个错误,我们不知道它是什么。你们能解释一下吗?这是错误:

at process._tickCallback (internal/process/next_tick.js:188:7)
(node:10758) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwin
g inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch().
 (rejection id: 2335)

PS:我的朋友不允许我发布代码。

1 个答案:

答案 0 :(得分:1)

当开发人员忘记通过.catch()try... catch添加异步错误处理时,会发生此错误。比较:

(async function main() {
  try {
    await Promise.reject();
  } catch (err) {
    console.error('Rejection handled.');
  }
})();
Rejection handled.
(async function main() {
  await Promise.reject();
})();
UnhandledPromiseRejectionWarning: ...