Shard #1 and #2 work, but Shard #3 fails at startup

What's the problem? Hello! I am hosting a bot in ~8k servers. Recently, I have been encountering an issue during startup. Shard #1 and Shard #2 start perfectly. However, Shard #3 fails to start (hindering ongoing startups). What have you tried From the error and logging, I have not yet identified the issue. I can imagine several reasons that I could not verify - Guild in shard #3 is bugged - Recent update? I use the newest stable discord.js - I also tried increasing the startup time limit Error:
0|. | Shard #3 is online.
0|. | Error [ShardingReadyTimeout]: Shard 3's Client took too long to become ready.
0|. | at Timeout.onTimeout (/root/snaky/node_modules/discord.js/src/sharding/Shard.js:190:16)
0|. | at listOnTimeout (node:internal/timers:573:17)
0|. | at process.processTimers (node:internal/timers:514:7) {
0|. | code: 'ShardingReadyTimeout'
0|. | }
0|. | Shard #3 is online.
0|. | Error [ShardingReadyTimeout]: Shard 3's Client took too long to become ready.
0|. | at Timeout.onTimeout (/root/snaky/node_modules/discord.js/src/sharding/Shard.js:190:16)
0|. | at listOnTimeout (node:internal/timers:573:17)
0|. | at process.processTimers (node:internal/timers:514:7) {
0|. | code: 'ShardingReadyTimeout'
0|. | }
Sharding Code:
var manager = new ShardingManager("./bot.js", {
token: auth[key],
execArgv: ['--trace-uncaught', '--trace-warnings', '--inspect=0'],
totalShards: 'auto',
timeout: 120_000
});

manager.spawn({ amount: 'auto', delay: 10000, timeout: 120000});

// Track when all shards are ready
let readyShards = new Set();
manager.on("shardCreate", shard => {
console.log(`Shard #${shard.id} is online.`); // THIS FIRES FOR SHARD 1, 2, and 3

shard.on("ready", () => { // THIS ONLY FIRES FOR SHARD 1 and 2
readyShards.add(shard.id);
console.log(`Shard #${shard.id} is ready. (${readyShards.size}/${manager.totalShards} shards ready)`);

if (readyShards.size === manager.totalShards) {
console.log("All shards are now ready!");
}
});
});
}
var manager = new ShardingManager("./bot.js", {
token: auth[key],
execArgv: ['--trace-uncaught', '--trace-warnings', '--inspect=0'],
totalShards: 'auto',
timeout: 120_000
});

manager.spawn({ amount: 'auto', delay: 10000, timeout: 120000});

// Track when all shards are ready
let readyShards = new Set();
manager.on("shardCreate", shard => {
console.log(`Shard #${shard.id} is online.`); // THIS FIRES FOR SHARD 1, 2, and 3

shard.on("ready", () => { // THIS ONLY FIRES FOR SHARD 1 and 2
readyShards.add(shard.id);
console.log(`Shard #${shard.id} is ready. (${readyShards.size}/${manager.totalShards} shards ready)`);

if (readyShards.size === manager.totalShards) {
console.log("All shards are now ready!");
}
});
});
}
I appreciate any help and hints. Thank you!
9 Replies
d.js toolkit
d.js toolkit2d ago
ByBloomy_
ByBloomy_2d ago
Increase your delay even more, but i dont see why it takes that long
Jonas
JonasOP2d ago
I increased it by times ten, and it did not change
var manager = new ShardingManager("./bot.js", {
token: auth[key],
execArgv: ['--trace-uncaught', '--trace-warnings', '--inspect=0'],
totalShards: 'auto',
timeout: 920_000
});

manager.spawn({ amount: 'auto', delay: 100000, timeout: 120000});
var manager = new ShardingManager("./bot.js", {
token: auth[key],
execArgv: ['--trace-uncaught', '--trace-warnings', '--inspect=0'],
totalShards: 'auto',
timeout: 920_000
});

manager.spawn({ amount: 'auto', delay: 100000, timeout: 120000});
ByBloomy_
ByBloomy_2d ago
Its in you spawn command
Jonas
JonasOP2d ago
Yes I changed both delay in the spawn command and timeout for the manager
ByBloomy_
ByBloomy_2d ago
And if it doesnt resolve, you will need to debug on the start on the shard what does take so long it timeouts
Jonas
JonasOP2h ago
How could I do that? Is there a logging I could do to identify whether it's freezing due to e.g., the servers being loaded?
ByBloomy_
ByBloomy_2h ago
yes, adding loging in your bot.js file
Jonas
JonasOP2h ago
Thanks to you both, I will try and keep you both updated

Did you find this page helpful?