[英]How to avoid http2 connect from crashing Node.js
const client = http2.
connect('https://domain.doesnt.exist').
on('error', e => {
console.error(e.message);
});
在 Node.js 13.6.0 上,即使提供了錯誤偵聽器,上述代碼也會使整個過程崩潰。
我將如何避免它?
您可以使用uncaughtException
事件來記錄所有uncaughtException
異常..
process.on('uncaughtException', err => {
console.log(err.message);
console.log(err.stack);
process.exit(1)
})
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.