Network errors

Hi, i have two bots hosted on my Raspberry Pi 5 with pm2, i noticed that sometimes one of the bots when my internet goes down it throws some errors (they are in the screenshot) and doesn't reconnect to discord after the connection returns. My other bot instead doesn't give any errors and just reconnects as it should. It's strange because this doesn't happen everytime, i just tried unplugging the ethernet cable and this time all of the bots reconnected without errors. Is there a way to fix this? My node version is v20.10.0 The discord.js version on the bot that sometimes throws errors is v14.15.3 and the bot that reconnects without errors as it should has version v14.14.1
No description
14 Replies
d.js toolkit
d.js toolkit6mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - Marked as resolved by staff
AlexDiego123
AlexDiego123OP6mo ago
It looks like discord.js is already handling the error? The process is not exiting and pm2 is not restarting it
monbrey
monbrey6mo ago
No, that error would normally be a crash Theres nothing we can do about network issues, it comes down to your error handling
AlexDiego123
AlexDiego123OP6mo ago
but there's no error handling that prevents it from crashing
AlexDiego123
AlexDiego123OP6mo ago
hey i think i figured this out but how do i handle this error? i already tried with the 'error' event and with Discord.Events.ShardError but this always crashes the bot and the stack trace in the error isn't really helpful
No description
AlexDiego123
AlexDiego123OP6mo ago
as i already said i have another bot that has version 14.14.1 instead of 14.15.3 and is written in javascript instead of typescript and that bot is not giving this error and is just reconnecting when my network comes back up
AlexDiego123
AlexDiego123OP6mo ago
i noticed that with debug logs enabled the bot that doesn't crash says The gateway closed with an unexpected code 1006, attempting to resume. and then tries to reconnect until internet is working but instead the other bot in typescript that is giving me problems doesn't say this and stops at Waiting for event hello for 60000ms because then the error occurs and the bot restarts without a connection and it doesn't retry connecting
No description
horohousu
horohousu6mo ago
this isn't djs related though
AlexDiego123
AlexDiego123OP6mo ago
Well I’m trying to handle an error that comes from discord.js so this should be djs related
horohousu
horohousu6mo ago
the code "EAI_AGAIN" is a DNS related error
AlexDiego123
AlexDiego123OP6mo ago
yes i know because sometimes my router restarts and it's not my dns it's because while it restarts there's no internet but i can't figure out why my other bot is not giving this error and is just reconnecting instead this one is giving this error and then it crashes and doesn't reconnect how do i handle this error I downgraded the discord.js of the bot to the one that my other bot that is not giving this error has and still it's giving this error and i have to fix this
Zerls
Zerls6mo ago
as said previously, this is not a d.js issue, you're asking in the wrong channel
GitHub
GitHub6mo ago
:issue_closed: #10372 in discordjs/discord.js by Pyr33x closed <t:1719948139:R> Unhandled 'error' event emitted
AlexDiego123
AlexDiego123OP6mo ago
i also asked in other-js-ts #Handling network errors
Want results from more Discord servers?
Add your server