How to catch a global error with NodeJS

前端 未结 2 1718
悲&欢浪女
悲&欢浪女 2020-12-11 05:42

I am getting an unhandled error but not sure where it\'s coming from. My app has several http.request(options, callback).end() in different methods, with the callback\'s tra

2条回答
  •  遥遥无期
    2020-12-11 06:11

    ECONNRESET means that the other side of the TCP connection is aborted. You could look at the server logs, but since it was random times this makes me think that the server becomes overloaded and kills a few connections.

    If you're starting a process at any point in the process try the below:

    process.on('uncaughtException', function (err) {
      console.error(err.stack);
      console.log("Node NOT Exiting...");
    });
    

提交回复
热议问题