ECONNRESET Aborted error randomly during node process

Viewed 1335

My node js application ( a discord bot ) keeps crashing with the Error: aborted message and code ECONNRESET. I have some some digging and it seems that the issue occurs when the other end of a TCP connection hangs up abruptly.

The error message I always get:

Error: aborted
    at connResetException (node:internal/errors:631:14)
    at TLSSocket.socketCloseListener (node:_http_client:438:27)
    at TLSSocket.emit (node:events:388:22)
    at node:net:666:12
    at TCP.done (node:_tls_wrap:573:7) {
code: 'ECONNRESET'
}

As you can see the error message is not very useful and doesn't provide any informatino as to where the error happened. I am getting the error through the node process.on('uncaughtException', err => {}) exception handler.

I am using discord.js ^12.5.1 node 15.4.0 and axios ^0.21.1 although the error seems to occur randomly and looking through the logs there is never a specific function call that triggers it and sometimes it happens whilst no functions have even been called.

The error happens sporadically as well. Sometimes it happens once a day and other times it will happen 5 times in an hour.

I should also add I am using the Heroku free tier for hosting,

If anyone could shed some light that would be very useful.

0 Answers
Related