discord.js
discord.js copied to clipboard
Shard 0's process exited before its Client became ready.
Please describe the problem you are having in as much detail as possible: I start the bot, when it starts using the ShardingManaer i get this error.
StriderM | Error [SHARDING_IN_PROCESS]: Shards are still being spawned.
StriderM | (node:1) UnhandledPromiseRejectionWarning: Error [SHARDING_READY_DIED]: Shard 0's process exited before its Client became ready.
then after it crashes with no other data, somethimes i get this
StriderM | (node:1) UnhandledPromiseRejectionWarning: Error [SHARDING_READY_DIED]: Shard 0's process exited before its Client became ready.
StriderM | at Shard.onDeath (/usr/src/Strider/node_modules/discord.js/src/sharding/Shard.js:158:16)
StriderM | at Object.onceWrapper (events.js:422:26)
StriderM | at Shard.emit (events.js:315:20)
StriderM | at Shard._handleExit (/usr/src/Strider/node_modules/discord.js/src/sharding/Shard.js:384:10)
StriderM | at ChildProcess.emit (events.js:315:20)
StriderM | at Process.ChildProcess._handle.onexit (internal/child_process.js:277:12)
Include a reproducible code sample here, if possible:
Sharding Manager:
// Import All The Packages
require("dotenv").config();
const { ShardingManager } = require("discord.js");
// Create Your ShardingManger Instance
const manager = new ShardingManager("./index.js", {
execArgv: ['--trace-warnings'],
token: process.env.TOKEN,
shardArgs: ["--color"]
});
// Spawn The Shards
manager.spawn();
index file:
const { Client } = require("discord.js");
const client = new Client({
ws: { intents: 32511 },
restTimeOffset: 0,
rateLimitAsError: true,
disableMentions: "everyone",
}); // Require The Bot Client
// Get Our Packages
const glob = require("glob");
// Command & Event Files Using Glob
const commandFiles = glob.sync("./Helpers/commands/**/*.js");
for (const file of commandFiles) {
const command = require(file);
client.commands.set(command.name, command);
}
const eventFiles = glob.sync("./Helpers/events/**/*.js");
for (const file of eventFiles) {
const event = require(file);
const eventName = /\/events.(.*).js/.exec(file)[1];
client.on(eventName, event.bind(null, client));
}
// Login To The Discord API
client.login(process.env.TOKEN).catch(console.error);
Further details:
- discord.js version: v12.15.1
- Node.js version: v14.15.4
- Operating system: Ubunte
- Priority this issue should have – please be realistic and elaborate if possible: Urgent, i have 3 friends getting this issue... my bot has been down for 3 days now and my friends have been down a week...
Relevant client options:
- partials: none
- gateway intents: 32511 (Everything except Presence Intent, yes i do have the Members Intent)
- other: verified bot
similar error here
Started getting this also
i have the error
This error occurs when the spawned process (the shard), died for whatever reason before its client emitted ready.
If it crashed due to an error, it'll be printed to stderr as usual before exiting (so above that error).
If the process exited naturally or by calling process.exit
(which all of your dependencies can do too), there won't be anything in the output about that.
It would be helpful if you could update your reproducible sample to be minimal too. Without the command and event handling part, as that's not discord.js. (While still making sure the reported behavior is still happening!)
On an unrelated note: There is no rateLimitAsError
option, it will just be ignored.
I also got this error on master branch but not latest version!
This was troubling me for quite some time. In order to catch these types of errors, or errors that occur during respawn, you must add an error event listener to the shard as it's being created:
manager.on('shardCreate', async (shard) => {
console.log('Shard Launched')
shard.on('error', (error) => {
console.error(error)
})
})
This should prevent the uncaught error in the parent process. If respawn: true
is set on the manager, the child process will restart automatically.
Are you able to reproduce this issue with discord.js v13.3.1? I'm rewriting the sharder so it'd be helpful to know if the issue still persists.
I have absolutely no clue, but I'll try it when I have some free time and notify you with the results
Does anyone know how to fix this?