discord.js
discord.js copied to clipboard
SHARDING_READY_TIMEOUT Shard 0's Client took too long to become ready.
Issue description
My bot is currently at 11 shards for it, and when I try to start the bot on my VPS which has 4vCores and 4GB of ram, one shard out of the 11 randomly takes too long to respond, and it causes every other shard to stop launching. This is happening every time now when I try to start the bot, however when I run the bot on my own Machine with 32GB of ram, and an i7 9700k, the bot works perfectly fine and all 11 shards launch perfectly fine.
I've tried it on 2 seperate VPS's, with the same ram and cores, different operating systems and still the same issue. The owners of the hosting company have also increased the ram of the VPS to 32GB just like my main PC, and still same issue of SHARDING READY TIMEOUT.
Does anyone have any ideas for this as to what could be causing it, and why this only happens on the VPS's, and not on my own machine?
Below is my sharding file.
I've tried multiple solutions that I could find anywhere, including on this github for Discord.js
Including https://github.com/discordjs/discord.js/issues/2323
and https://github.com/discordjs/discord.js/issues/3956 but to no conclusion or solution.
I have marked this as medium attention just due to this has been going on for the last several weeks as the bot gets bigger and bigger, and I have been unable to come to any solution in regards to this issue and my bot is now currently being forced to stay offline since now it won't go past Shard 2 taking too long to be ready.
Code sample
const { ShardingManager } = require('discord.js');
const { token, dblToken } = require('./cfg.json');
const manager = new ShardingManager('./bot.js', {
token,
totalShards: 11,
respawn: true,
spawnTimeout = -1
});
const { AutoPoster } = require('topgg-autoposter')
const ap = AutoPoster(dblToken, manager)
manager.on("shardCreate", shard => {
shard.on('reconnecting', () => {
console.log(`Reconnecting shard: [${shard.id}]`);
});
shard.on('spawn', () => {
console.log(`Spawned shard: [${shard.id}]`);
});
shard.on('ready', () => {
console.log(` Shard [${shard.id}] is ready`);
});
shard.on('death', () => {
console.log(`Died shard: [${shard.id}]`);
});
shard.on('error', (err)=>{
console.log(`Error in [${shard.id}] with : ${err} `)
shard.respawn()
})
});
ap.on('posted', () => {
console.log('Posted Stats.')
})
manager.spawn();
discord.js version
13.4.0
Node.js version
v17.3.0
Operating system
Was tested on Linux and Windows.
Priority this issue should have
Medium (should be fixed soon)
Which partials do you have configured?
No Partials
Which gateway intents are you subscribing to?
GUILDS, GUILD_MESSAGES, GUILD_MESSAGE_REACTIONS
I have tested this issue on a development release
No response
I have the same issue on my Linux VPS. I can't get past shard 0 now. I start it in nodemon, launches the shard. Bot connects to channel and immediately timesout but creates another instance of the bot. Luckily for me, I can use CTRL + C to close out the task and shut down both instances of the bot.
So I’d like to take a point on this. When looking at the code it seems Discord.js uses Promise.all
when spawning shards. which if one of the process were to error the rest won’t be executed hence when you get the error the rest of shards aren’t spawned or do nothing.
Should not be stale.. This issue still valid.
So I’d like to take a point on this. When looking at the code it seems Discord.js uses
Promise.all
when spawning shards. which if one of the process were to error the rest won’t be executed hence when you get the error the rest of shards aren’t spawned or do nothing.
That’s not true, just because the Promise.all will reject on the rejection of one of the promises doesn’t magically stop the other asynchronous functions from running. It’s just that their resolution/rejection won’t matter for the Promise.all anymore. But the other shards will keep on connecting.
Has anyone find a fix to this issue? Thank you
Hello same issue, I've tried to restart it several times already. Even with a change of token to cut it, always the same problem.
Error [SHARDING_READY_TIMEOUT]: Shard 0's Client took too long to become ready.
12|| at Timeout.onTimeout (*/node_modules/discord.js/src/sharding/Shard.js:166:16)
12|| at listOnTimeout (node:internal/timers:557:17)
12|| at processTimers (node:internal/timers:500:7) {
12|| [Symbol(code)]: 'SHARDING_READY_TIMEOUT'
12|| }
Version discord.js : 13.6.0 Version Node.js : 17.0.1
Same problem.
I'm also having the same issue. Need help ASAP
Hello @aelxxs, for my part I edited my code, and he works :
const shard = new ShardingManager("./core.js", {
totalShards: "auto",
token: config.token,
timeout: -1,
respawn: true
})
shard.on('shardCreate', shard => {
console.log(`Shard ID #${shard.id}`)
})
shard.spawn({ amount: 'auto', delay: 5500, timeout: 30000 }).catch(e => console.log(e))
Hello @aelxxs, for my part I edited my code, and he works :
const shard = new ShardingManager("./core.js", { totalShards: "auto", token: config.token, timeout: -1, respawn: true }) shard.on('shardCreate', shard => { console.log(`Shard ID #${shard.id}`) }) shard.spawn({ amount: 'auto', delay: 5500, timeout: 30000 }).catch(e => console.log(e))
Thanks! I ended up having to update to a newer (supported) version of Discord.JS. My bot was really outdated.
It works great now. Don't know what the cause of the error is though.
also having this issue on latest version
Thanks! I ended up having to update to a newer (supported) version of Discord.JS. My bot was really outdated.
It works great now. Don't know what the cause of the error is though.
@aelxxs Hmmm I got the error again with these settings... 😡
Edited the shard.spawn
conf with
shard.spawn({ amount: 'auto', delay: 15500, timeout: 60000 }).catch(e => console.log(e))
Seems better 🤔
Thanks! I ended up having to update to a newer (supported) version of Discord.JS. My bot was really outdated. It works great now. Don't know what the cause of the error is though.
@aelxxs Hmmm I got the error again with these settings... 😡
Edited the
shard.spawn
conf withshard.spawn({ amount: 'auto', delay: 15500, timeout: 60000 }).catch(e => console.log(e))
Seems better 🤔
Nice, I don't really know what caused the issue. I'm moving away from Discord.JS though so I won't be bothering with finding a solution