如何避免http2连接崩溃Node.js

问题描述 投票:0回答:1
  const client = http2.
    connect('https://domain.doesnt.exist').
    on('error', e => {
      console.error(e.message);
    });

在Node.js 13.6.0上,即使提供了错误侦听器,上面的代码也会使整个过程崩溃。

我将如何避免这种情况?

node.js http2
1个回答
0
投票

您可以使用uncaughtException事件记录所有未捕获的异常。.>

process.on('uncaughtException', err => {
  console.log(err.message);
  console.log(err.stack);
  process.exit(1)
})
© www.soinside.com 2019 - 2024. All rights reserved.