Init tapdata...
(node:22121) 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(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:22121) [DEP0018] 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.
部署启动tapdata时报错,谁知这个是什么原因吗?
您的代码中存在 Promise 没有被正确处理的情况,可能会导致程序出现异常情况而未被处理,进一步导致程序崩溃。
您可以尝试添加一个 catch() 语句来处理未捕获的 Promise 异常。例如:
tapdata.connect().then(() => {
// 连接成功后的操作
}).catch((err) => {
// 处理异常情况
console.error(err);
});
或者您可以在启动程序时添加 --unhandled-rejections=strict 参数,使程序在出现未捕获的 Promise 异常时强制终止,以便您及时发现问题并进行处理。例如:
node --unhandled-rejections=strict app.js