ERROR: Shard 29's Client took too long to become ready

I have a bot where it comes up with this error randomly and causes the bot to crash, I then need to restart the server. any ideas how to resolve? here's the sharding code:
import dotenv from 'dotenv';
import { ShardingManager } from 'discord.js';

dotenv.config();
const manager = new ShardingManager('./src/bot.js', {
token: process.env.DISCORD_BOT_TOKEN,
respawn: true, // Automatically respawn shards if they fail
timeout: 120_000 // Increase timeout to 120 seconds
});

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

manager.spawn({ delay: 5000 }) // Adds a 5-second delay between shards
.then(() => console.log('All shards launched successfully.'))
.catch(error => console.error('Error while spawning shards:', error));
import dotenv from 'dotenv';
import { ShardingManager } from 'discord.js';

dotenv.config();
const manager = new ShardingManager('./src/bot.js', {
token: process.env.DISCORD_BOT_TOKEN,
respawn: true, // Automatically respawn shards if they fail
timeout: 120_000 // Increase timeout to 120 seconds
});

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

manager.spawn({ delay: 5000 }) // Adds a 5-second delay between shards
.then(() => console.log('All shards launched successfully.'))
.catch(error => console.error('Error while spawning shards:', error));
2 Replies
d.js toolkit
d.js toolkit4d 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!
NP
NPOP3d ago
what would you suggest? 300 seconds or more than that? alr ty

Did you find this page helpful?