Node.js Sentry 错误捕获不起作用

Aka*_*dey 0 node.js sentry

在 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);
Run Code Online (Sandbox Code Playgroud)

小智 5

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