簡體   English   中英

如何避免 http2 連接崩潰 Node.js

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM