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
14 Replies
- 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 staffIt looks like discord.js is already handling the error? The process is not exiting and pm2 is not restarting it
No, that error would normally be a crash
Theres nothing we can do about network issues, it comes down to your error handling
but there's no error handling that prevents it from crashing
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
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
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 connectingthis isn't djs related though
Well I’m trying to handle an error that comes from discord.js so this should be djs related
the code "EAI_AGAIN" is a DNS related error
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
as said previously, this is not a d.js issue, you're asking in the wrong channel
:issue_closed: #10372 in discordjs/discord.js by Pyr33x closed <t:1719948139:R>
Unhandled 'error' event emitted
i also asked in other-js-ts #Handling network errors