const client = http2.
connect('https://domain.doesnt.exist').
on('error', e => {
console.error(e.message);
});
在Node.js 13.6.0上,即使提供了错误侦听器,上面的代码也会使整个过程崩溃。
我将如何避免这种情况?
您可以使用uncaughtException
事件记录所有未捕获的异常。.>
process.on('uncaughtException', err => {
console.log(err.message);
console.log(err.stack);
process.exit(1)
})