Bot Shards Keep Reconnecting After Reboot

Has anybody else experienced a similar issue where their traditionally sharded bot gets stuck in a shard reconnect and bot restart loop after its first restarted? I've been having this issue for a while now and haven't been able to find the cause. I've gotten a mix of errors before this occurs such as IP discovery problems and Error [ERR_IPC_CHANNEL_CLOSED]: Channel closed . Any recommendations? I feel like I've tried everything.
14 Replies
d.js toolkit
d.js toolkit14mo ago
• What's your exact discord.js npm list discord.js and node node -v version? • Post the full error stack trace, not just the top part! • Show your code! • Explain what exactly your issue is. • Not a discord.js issue? Check out #useful-servers.
d.js docs
d.js docs14mo 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
dzlandis
dzlandis14mo ago
I've added that. Will update when additional logging info is provided.
dzlandis
dzlandis14mo ago
@qjuh is this more helpful?
dzlandis
dzlandis14mo ago
That's just a portion of the logs. It's difficult to sift through them and find exactly what causes the issue. I'll do my best though.
Mac
Mac14mo ago
log the stuff to a file if that helps
dzlandis
dzlandis14mo ago
Are these errors normal though? They occur right after I've recovered from the error and am restarting back up the bot 🤔
Mac
Mac14mo ago
best thing to do rn is log that to a file and send the whole file here
dzlandis
dzlandis14mo ago
I mean, there would be nothing more than what's in that screenshot. It's just that error repeating across multiple shards. Still trying to find the first cause which causes the spiral
dzlandis
dzlandis14mo ago
There's a few of these sprinkled throughout but nothing out of the usual tmk
dzlandis
dzlandis14mo ago
This is the first occurrence of Invalid Session. Prior to this, Shard 0 is heartbeating normally.
dzlandis
dzlandis13mo ago
It's difficult to tell exactly. But this is the most recent occurrence of an issue that occurred on v14.11 whereas the previous one may have been on an earlier version of DJS.
21:33:40: [WS => Shard 34] Destroying shard
21:33:40: Reason: Told to reconnect by Discord
21:33:40: Code: 4200
21:33:40: Recover: Resume
21:33:40: [WS => Shard 34] Connection status during destroy
21:33:40: Needs closing: true
21:33:40: Ready state: 1
21:33:40: ^[[90m21:33:40 07-05-2023^[[39m ^[[36mDEBUG ^[[39m^[[95m3623810^[[39m ^[[90m(^[[39m^[[34mscriptly^[[39m:^[[32mshards^[[39m^[[90m)^[[39m: Shard #34 reconnecting.
21:33:41: [WS => Shard 34] Connecting to wss://gateway-us-east1-b.discord.gg?v=10&encoding=json&compress=zlib-stream
21:33:41: [WS => Shard 34] Waiting for event hello for 60000ms
21:33:41: ^[[90m21:33:41 07-05-2023^[[39m ^[[34mINFO ^[[39m^[[95m3623428^[[39m ^[[90m(^[[39m^[[34mscriptly^[[39m^[[90m)^[[39m: Someone used TTS (google = es-MX) (3 chars)| tts
21:33:41: [VOICE] received voice state update: {"member":{"user":{"username":"Scriptly","public_flags":65536,"id":"830626887779876884","global_name":null,"display_name":null,"discriminator":"8847","bot":true,"avatar_decoration":null,"avatar":"b48064c96671d353c64ff3da109>
21:33:41: [WS => Shard 34] Preparing first heartbeat of the connection with a jitter of 0.9711397273308446; waiting 40059ms
21:33:41: [WS => Shard 34] Resuming session
21:33:41: resume url: wss://gateway-us-east1-b.discord.gg
21:33:41: sequence: 22284
21:33:41: shard id: 34
21:33:41: [WS => Shard 34] Resumed and replayed 4 events
// bot gets completely restarts and gets stuck in loop
21:33:40: [WS => Shard 34] Destroying shard
21:33:40: Reason: Told to reconnect by Discord
21:33:40: Code: 4200
21:33:40: Recover: Resume
21:33:40: [WS => Shard 34] Connection status during destroy
21:33:40: Needs closing: true
21:33:40: Ready state: 1
21:33:40: ^[[90m21:33:40 07-05-2023^[[39m ^[[36mDEBUG ^[[39m^[[95m3623810^[[39m ^[[90m(^[[39m^[[34mscriptly^[[39m:^[[32mshards^[[39m^[[90m)^[[39m: Shard #34 reconnecting.
21:33:41: [WS => Shard 34] Connecting to wss://gateway-us-east1-b.discord.gg?v=10&encoding=json&compress=zlib-stream
21:33:41: [WS => Shard 34] Waiting for event hello for 60000ms
21:33:41: ^[[90m21:33:41 07-05-2023^[[39m ^[[34mINFO ^[[39m^[[95m3623428^[[39m ^[[90m(^[[39m^[[34mscriptly^[[39m^[[90m)^[[39m: Someone used TTS (google = es-MX) (3 chars)| tts
21:33:41: [VOICE] received voice state update: {"member":{"user":{"username":"Scriptly","public_flags":65536,"id":"830626887779876884","global_name":null,"display_name":null,"discriminator":"8847","bot":true,"avatar_decoration":null,"avatar":"b48064c96671d353c64ff3da109>
21:33:41: [WS => Shard 34] Preparing first heartbeat of the connection with a jitter of 0.9711397273308446; waiting 40059ms
21:33:41: [WS => Shard 34] Resuming session
21:33:41: resume url: wss://gateway-us-east1-b.discord.gg
21:33:41: sequence: 22284
21:33:41: shard id: 34
21:33:41: [WS => Shard 34] Resumed and replayed 4 events
// bot gets completely restarts and gets stuck in loop
After the first restart after the above error, after the following happens, it restarts again:
21:34:12: [WS => Shard 34] Identifying
21:34:12: shard id: 34
21:34:12: shard count: 42
21:34:12: intents: 36529
21:34:12: compression: zlib-stream
21:34:12: [WS => Shard 34] Waiting for event ready for 15000ms
21:34:12: [WS => Shard 34] Identifying
21:34:12: shard id: 34
21:34:12: shard count: 42
21:34:12: intents: 36529
21:34:12: compression: zlib-stream
21:34:12: [WS => Shard 34] Waiting for event ready for 15000ms
Occurs with the same shard it seems And then after that, all the shards start having problems after it reconnects again I do use pm2. I've checked the error logs and I've not found anything out of the ordinary Also, can you clarify what you mean be restarting the pm2 daemon? I usually just update my stuff, and then run a pm2 restart and everything works And I don't think there are any errors when it completely restarts. But at the same time, it's also difficult to tell when it is completely restarting. I do get this error sometimes since I use discord-hybrid-sharding:
14:08:04: node_modules/discord-hybrid-sharding/dist/Core/Cluster.js:154
14:08:04: reject(new Error('CLUSTERING_READY_TIMEOUT | ClusterId: ' + this.id));
14:08:04: ^
14:08:04:
14:08:04: Error: CLUSTERING_READY_TIMEOUT | ClusterId: 0
14:08:04: at Timeout.onTimeout (node_modules/discord-hybrid-sharding/dist/Core/Cluster.js:154:24)
14:08:04: at listOnTimeout (node:internal/timers:569:17)
14:08:04: at process.processTimers (node:internal/timers:512:7)
14:08:04: Emitted 'error' event on Cluster instance at:
14:08:04: at node_modules/discord-hybrid-sharding/dist/Core/Cluster.js:288:44
14:08:04: node_modules/discord-hybrid-sharding/dist/Core/Cluster.js:154
14:08:04: reject(new Error('CLUSTERING_READY_TIMEOUT | ClusterId: ' + this.id));
14:08:04: ^
14:08:04:
14:08:04: Error: CLUSTERING_READY_TIMEOUT | ClusterId: 0
14:08:04: at Timeout.onTimeout (node_modules/discord-hybrid-sharding/dist/Core/Cluster.js:154:24)
14:08:04: at listOnTimeout (node:internal/timers:569:17)
14:08:04: at process.processTimers (node:internal/timers:512:7)
14:08:04: Emitted 'error' event on Cluster instance at:
14:08:04: at node_modules/discord-hybrid-sharding/dist/Core/Cluster.js:288:44
But the people who support the package discord-hybrid-sharding have assured me time and time again that this is not an issue with their package and is instead an issue on my end. I don't think that is the issue as this error was occuring in v14.9 as well
Unknown User
Unknown User13mo ago
Message Not Public
Sign In & Join Server To View
dzlandis
dzlandis13mo ago
I've already set it to -1