【问题标题】:Node.js Sentry error caputuring not workingNode.js Sentry 错误捕获不起作用
【发布时间】:2019-03-02 08:55:54
【问题描述】:

在 Node.js 8 中,如果我在代码末尾使用 process.exit(0),我将无法捕获哨兵错误。否则它工作正常

const Sentry = require('@sentry/node');
Sentry.init({ dsn: 'https://c3f5****************34dbf@sentry.io/1288850' });
try{
    throw new Error('test-error');
}
catch(e){
    const Eid = Sentry.captureException(e);
    console.log(Eid);
}
process.exit(0);

【问题讨论】:

  • 使其成为异步函数。

标签: node.js sentry


【解决方案1】:

Sentry.captureException(e) 是异步的,因此 process.exit(0) 在 Sentry.captureException 能够运行之前终止进程。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-10-06
    • 2014-03-25
    • 2017-01-18
    • 1970-01-01
    • 1970-01-01
    • 2016-09-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多