在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);
答案 0 :(得分:0)
Sentry.captureException(e)是异步的,因此process.exit(0)在Sentry.captureException能够运行之前终止了该进程。