繁体   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