Auto-shard calculation fails: Sharding is required error

Environment: - Discord.js: 14.22.1 I want the ClusterManager to calculate the number of shards automatically. My code:
const manager = new ClusterManager(path.join(__dirname, 'bot.js'), {
mode: 'process',
token: process.env.token,
totalShards: 3,
totalClusters: 1,
spawnOptions: {
timeout: 30000,
delay: 8000,
},
});
const manager = new ClusterManager(path.join(__dirname, 'bot.js'), {
mode: 'process',
token: process.env.token,
totalShards: 3,
totalClusters: 1,
spawnOptions: {
timeout: 30000,
delay: 8000,
},
});
When I remove totalShards to let the manager calculate it, I get the following errors from the djs shardDisconnect event:
[ShardID: 0] disconnected with error: the reason property is deprecated, use the code property to determine the reason
Error: Sharding is required
CLUSTERING_NOT_READY | Cluster is not ready yet (#5)
[ShardID: 0] disconnected with error: the reason property is deprecated, use the code property to determine the reason
Error: Sharding is required
CLUSTERING_NOT_READY | Cluster is not ready yet (#5)
Question: How do I properly enable automatic shard calculation without encountering the Sharding is required error? Is there a specific setup required in bot.js when letting the ClusterManager handle shards automatically?
4 Replies
Digital
Digital2mo ago
sorry i was little away, so for first one, it looks like djs error, no idea since sharding doesnt use reason anywhere, for second, uh, only what i can think of is discord returning single shard for some reason, you can see manually waht it returns by fetching /api/gateway/bot with bot's token to manually check, and last error is just that you're trying to use broadcastEval before cluster is well, ready
notvexi
notvexiOP2mo ago
ah okay but why does it then work if i set the shards manually
Digital
Digital2mo ago
i would need to know response of that gateway/bot to know if its wrongly returning or smth cuz if it returns 1, for shards, then well it makes sense why it breaks
notvexi
notvexiOP2mo ago
ok

Did you find this page helpful?