My bot disconnect randomly and I don't know why

I have a spaghetti bot that is on ~150 servers, so I no need to shard (normally?). I use Enmap for the database, plus some caching at start. The bot is self-hosted on a raspberry pi 5 (8GB) (+NVM SSD) with PM2 with some other bot, and it's the only that got disconnecting. It's also the only with some memory usage (not more than 300mb). I added a lot of warn to get the error (copium). Here the code : https://github.com/Dicelette/discord-dicelette Tbh i'm totally clueless on this one. I don't know if I do something bad?
discord.js: 14.19.3
node: 20.15.0
pnpm: 10.12.1
discord.js: 14.19.3
node: 20.15.0
pnpm: 10.12.1
12 Replies
d.js toolkit
d.js toolkit3mo 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!
treble/luna
treble/luna3mo ago
You do not need to shard at 150. And what errors are you getting
Mara
MaraOP3mo ago
None, that's the problem. I have no log where disconnect, so I added a lot of console on each catch in hope to get it. But it shouldn't disconnect on catched error. Well, not online on discord … By discord ? Litterally, i check and notice that the bot have the not online icon ? I also created a secondary bot that ping me when the bot go off line
Mark
Mark3mo ago
is the node process for the bot still running or did it exit
Mara
MaraOP3mo ago
It continue to run, as I need to manually restart the pm2 process to get it reconnected again!
Ashish
Ashish3mo ago
I seem to be having the same issue, where the heartbeat randomly stops sent with my bot And it's only for one of my bots, rest work fine I used debug event from client and at some point it stops logging the heartbeat, bot goes offline, but the node process itself is alive
Mara
MaraOP3mo ago
Oh yeah, I can try to add it too. Do you have a snippet for integration into mine ? Maybe we can get something similar and debug together
d.js docs
d.js docs3mo ago
Please add the following code to your code base outside of any other event listeners and provide the full log output relevant to your issue.
client
.on("debug", console.log)
.on("warn", console.log)
client
.on("debug", console.log)
.on("warn", console.log)
- Note: if you initialize your Client as bot or other identifiers you need to use these instead of client - If the output is too long to post consider using a bin instead: gist | paste.gg | sourceb.in | hastebin
Mara
MaraOP3mo ago
thanks :>
dzlandis
dzlandis3mo ago
Any updates relating to this? I think its possible I may have a similar issue. Because in addition to getting OOM errors, I also have had problems with certain clusters going down and then getting automatically brought back up due to the way my cluster manager works. It happens so often that I end up running out of sessions and have to manually reset the token at least once a day. So I think it's possible it could also be a heartbeat related issue It's difficult to get debug logs of when that happens because, similar to this thread, there is no log where the disconnect occurs. It only just shuts off and gets restarted. But I also haven't turned on client debugging, so that would be the next step. I am using discord-hybrid-sharding though. So in their case, it may have stalled and needed to be manually restarted but theoretically hybrid sharding could have brought it back up automatically. The disconnect without logging is mainly what made me think it could be a similar issue. Of course, it could be unrelated, but I was just inquiring to see what else was discovered relating to this issue since its somewhat similar. It's difficult to narrow down issues like these. Happy to continue communicating in #General DJS Memory Leaks & Potential Voice Issues if you'd prefer.
Flo
Flo3mo ago
I have the same issue aswell, My Bot just goes offline with no signs at all, is yours verified aswell? it only happens to my verified bots.
dzlandis
dzlandis3mo ago
My bot is verified. Not fully confident my issue is related, though of course it's possible.

Did you find this page helpful?