Sharding not working anymore out of nowhere

Out of nowhere my bot isn't starting anymore, throwing a ShardingReadyDied every time after trying to start the seventh shard. I did not change anything with the host the bot is running on. The complete error looks like this:
error: new Error("Sharding is required")
^
Error: Sharding is required
at WebSocketShard.onClose (/home/container/node_modules/@discordjs/ws/dist/index.js:1114:18)
at connection.onclose (/home/container/node_modules/@discordjs/ws/dist/index.js:676:17)
at callListener (/home/container/node_modules/ws/lib/event-target.js:290:14)
at WebSocket.onClose (/home/container/node_modules/ws/lib/event-target.js:220:9)
at WebSocket.emit (node:events:519:28)
at WebSocket.emitClose (/home/container/node_modules/ws/lib/websocket.js:260:10)
at TLSSocket.socketOnClose (/home/container/node_modules/ws/lib/websocket.js:1272:15)
at TLSSocket.emit (node:events:531:35)
at node:net:338:12
at TCP.done (node:_tls_wrap:657:7)
Node.js v20.15.0
[11/07/2024-16:59:02.879] [ERROR] /home/container/node_modules/discord.js/src/sharding/Shard.js:178
reject(new DiscordjsError(ErrorCodes.ShardingReadyDied, this.id));
^
[11/07/2024-16:59:02.884] [ERROR] Error [ShardingReadyDied]: Shard 7's process exited before its Client became ready.
at Shard.onDeath (/home/container/node_modules/discord.js/src/sharding/Shard.js:178:16)
at Object.onceWrapper (node:events:634:26)
at Shard.emit (node:events:519:28)
at Shard.emit (node:domain:488:12)
at Shard._handleExit (/home/container/node_modules/discord.js/src/sharding/Shard.js:439:10)
at ChildProcess.emit (node:events:519:28)
at ChildProcess.emit (node:domain:488:12)
at Process.ChildProcess._handle.onexit (node:internal/child_process:294:12) {
code: 'ShardingReadyDied'
}
error: new Error("Sharding is required")
^
Error: Sharding is required
at WebSocketShard.onClose (/home/container/node_modules/@discordjs/ws/dist/index.js:1114:18)
at connection.onclose (/home/container/node_modules/@discordjs/ws/dist/index.js:676:17)
at callListener (/home/container/node_modules/ws/lib/event-target.js:290:14)
at WebSocket.onClose (/home/container/node_modules/ws/lib/event-target.js:220:9)
at WebSocket.emit (node:events:519:28)
at WebSocket.emitClose (/home/container/node_modules/ws/lib/websocket.js:260:10)
at TLSSocket.socketOnClose (/home/container/node_modules/ws/lib/websocket.js:1272:15)
at TLSSocket.emit (node:events:531:35)
at node:net:338:12
at TCP.done (node:_tls_wrap:657:7)
Node.js v20.15.0
[11/07/2024-16:59:02.879] [ERROR] /home/container/node_modules/discord.js/src/sharding/Shard.js:178
reject(new DiscordjsError(ErrorCodes.ShardingReadyDied, this.id));
^
[11/07/2024-16:59:02.884] [ERROR] Error [ShardingReadyDied]: Shard 7's process exited before its Client became ready.
at Shard.onDeath (/home/container/node_modules/discord.js/src/sharding/Shard.js:178:16)
at Object.onceWrapper (node:events:634:26)
at Shard.emit (node:events:519:28)
at Shard.emit (node:domain:488:12)
at Shard._handleExit (/home/container/node_modules/discord.js/src/sharding/Shard.js:439:10)
at ChildProcess.emit (node:events:519:28)
at ChildProcess.emit (node:domain:488:12)
at Process.ChildProcess._handle.onexit (node:internal/child_process:294:12) {
code: 'ShardingReadyDied'
}
4 Replies
d.js toolkit
d.js toolkit5mo 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!
Nils
NilsOP5mo ago
ShardingManager.js
const fs = require('fs');
const { ShardingManager } = require('discord.js');
require('console-stamp')(console, 'dd/mm/yyyy-HH:MM:ss.l');

require('dotenv').config();

const manager = new ShardingManager('./bot.js', {
token: process.env.TOKEN,
totalShards: Math.ceil(process.env.GUILDS / process.env.LIMIT),
timeout: -1,
respawn: true
});

console.log(`Shards to spawn: ${manager.totalShards}`);

manager.on('shardCreate', shard => console.log(`Shard ${shard.id} launched`));

manager.spawn({ amount: manager.totalShards, delay: 5500, timeout: 60000 })
.then(() => console.log(`All shards ready!`));
const fs = require('fs');
const { ShardingManager } = require('discord.js');
require('console-stamp')(console, 'dd/mm/yyyy-HH:MM:ss.l');

require('dotenv').config();

const manager = new ShardingManager('./bot.js', {
token: process.env.TOKEN,
totalShards: Math.ceil(process.env.GUILDS / process.env.LIMIT),
timeout: -1,
respawn: true
});

console.log(`Shards to spawn: ${manager.totalShards}`);

manager.on('shardCreate', shard => console.log(`Shard ${shard.id} launched`));

manager.spawn({ amount: manager.totalShards, delay: 5500, timeout: 60000 })
.then(() => console.log(`All shards ready!`));
Nils
NilsOP5mo ago
weird enough discord does not want to send the message with the bot.js, here it is in a pastebin https://pastebin.com/uRaweVq7
Pastebin
const fs = require('node:fs');const path = require('node:path');con...
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Nils
NilsOP5mo ago
what is weird though is that the bot worked completely fine before but now is crashing every time due to this error. I did not change anything at all. well this only pushes the error back to a different shard I just removed the totalshard limit so it automatically adjusts the number of shards and am receiving the same error as before, at a different shard tho it's shard 44 now ShardingManager.js
const fs = require('fs');
const { ShardingManager } = require('discord.js');
require('console-stamp')(console, 'dd/mm/yyyy-HH:MM:ss.l');

require('dotenv').config();

const manager = new ShardingManager('./bot.js', {
token: process.env.TOKEN,
timeout: -1,
respawn: true
});

console.log(`Shards to spawn: ${manager.totalShards}`);

manager.on('shardCreate', shard => console.log(`Shard ${shard.id} launched`));

manager.spawn({ amount: manager.totalShards, delay: 5500, timeout: 60000 })
.then(() => console.log(`All shards ready!`));
const fs = require('fs');
const { ShardingManager } = require('discord.js');
require('console-stamp')(console, 'dd/mm/yyyy-HH:MM:ss.l');

require('dotenv').config();

const manager = new ShardingManager('./bot.js', {
token: process.env.TOKEN,
timeout: -1,
respawn: true
});

console.log(`Shards to spawn: ${manager.totalShards}`);

manager.on('shardCreate', shard => console.log(`Shard ${shard.id} launched`));

manager.spawn({ amount: manager.totalShards, delay: 5500, timeout: 60000 })
.then(() => console.log(`All shards ready!`));
Error
[11/07/2024-19:55:05.290] [ERROR] Error [ShardingReadyDied]: Shard 44's process exited before its Client became ready.
at Shard.onDeath (/home/container/node_modules/discord.js/src/sharding/Shard.js:178:16)
at Object.onceWrapper (node:events:634:26)
at Shard.emit (node:events:519:28)
at Shard.emit (node:domain:488:12)
at Shard._handleExit (/home/container/node_modules/discord.js/src/sharding/Shard.js:439:10)
at ChildProcess.emit (node:events:519:28)
at ChildProcess.emit (node:domain:488:12)
at Process.ChildProcess._handle.onexit (node:internal/child_process:294:12) {
code: 'ShardingReadyDied'
}
[11/07/2024-19:55:05.290] [ERROR] Error [ShardingReadyDied]: Shard 44's process exited before its Client became ready.
at Shard.onDeath (/home/container/node_modules/discord.js/src/sharding/Shard.js:178:16)
at Object.onceWrapper (node:events:634:26)
at Shard.emit (node:events:519:28)
at Shard.emit (node:domain:488:12)
at Shard._handleExit (/home/container/node_modules/discord.js/src/sharding/Shard.js:439:10)
at ChildProcess.emit (node:events:519:28)
at ChildProcess.emit (node:domain:488:12)
at Process.ChildProcess._handle.onexit (node:internal/child_process:294:12) {
code: 'ShardingReadyDied'
}
Guilds is the number of guilds the bot is in, with limit I can adjust the total number of guilds per shard. I actually got it to work now with a higher guild number. I suspect the problem was too many guilds on one shard, however that wouldn't explain why auto sharding wasn't working. it's a bit of a workaround, but it's working now again at least Well if listed in app directory it shows the amount of guilds there there isn't actually I could try again, but since it's working now I wouldn't like to shut down the bot again and put it on auto alright I will try actually getting a completely new error now:
[11/07/2024-20:28:46.833] [ERROR] Error: spawn /usr/local/bin/node EAGAIN
at Process.ChildProcess._handle.onexit (node:internal/child_process:286:19)
at onErrorNT (node:internal/child_process:484:16)
at processTicksAndRejections (node:internal/process/task_queues:82:21) {
errno: -11,
code: 'EAGAIN',
syscall: 'spawn /usr/local/bin/node',
path: '/usr/local/bin/node',
spawnargs: [ '/home/container/bot.js' ]
}
[11/07/2024-20:28:46.833] [ERROR] Error: spawn /usr/local/bin/node EAGAIN
at Process.ChildProcess._handle.onexit (node:internal/child_process:286:19)
at onErrorNT (node:internal/child_process:484:16)
at processTicksAndRejections (node:internal/process/task_queues:82:21) {
errno: -11,
code: 'EAGAIN',
syscall: 'spawn /usr/local/bin/node',
path: '/usr/local/bin/node',
spawnargs: [ '/home/container/bot.js' ]
}
Want results from more Discord servers?
Add your server