Shard 0's process exited before its Client became ready

My bot was working fine and then I restarted it to make a small non breaking change and from now on even after reverting the change I get this error message:
Node.js v18.12.1
[INFO]: Shard [0] died
[INFO]: Spawned shard [0]
[INFO]: Error in [0]
[ERR]: Error [ShardingReadyDied]: Shard 0's process exited before its Client became ready.
[INFO]: Shard [0] died
[INFO]: Error in [0]
[ERR]: Error [ShardingReadyDied]: Shard 0's process exited before its Client became ready.
/Users/alex/Documents/Programming/node_modules/discord.js/src/sharding/Shard.js:201
this.worker.removeListener('exit', this._exitListener);
^

TypeError: Cannot read properties of null (reading 'removeListener')
at Shard.kill (/Users/alex/Documents/Programming/node_modules/discord.js/src/sharding/Shard.js:201:19)
at Shard.respawn (/Users/alex/Documents/Programming/node_modules/discord.js/src/sharding/Shard.js:223:10)
at Shard.<anonymous> (/Users/alex/Documents/Programming/src/shard.js:26:15)
at Shard.emit (node:events:513:28)
at /Users/alex/Documents/Programming/node_modules/discord.js/src/sharding/Shard.js:447:56
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
Node.js v18.12.1
[INFO]: Shard [0] died
[INFO]: Spawned shard [0]
[INFO]: Error in [0]
[ERR]: Error [ShardingReadyDied]: Shard 0's process exited before its Client became ready.
[INFO]: Shard [0] died
[INFO]: Error in [0]
[ERR]: Error [ShardingReadyDied]: Shard 0's process exited before its Client became ready.
/Users/alex/Documents/Programming/node_modules/discord.js/src/sharding/Shard.js:201
this.worker.removeListener('exit', this._exitListener);
^

TypeError: Cannot read properties of null (reading 'removeListener')
at Shard.kill (/Users/alex/Documents/Programming/node_modules/discord.js/src/sharding/Shard.js:201:19)
at Shard.respawn (/Users/alex/Documents/Programming/node_modules/discord.js/src/sharding/Shard.js:223:10)
at Shard.<anonymous> (/Users/alex/Documents/Programming/src/shard.js:26:15)
at Shard.emit (node:events:513:28)
at /Users/alex/Documents/Programming/node_modules/discord.js/src/sharding/Shard.js:447:56
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
I've tried uninstalling and reinstalling discord.js but to no avail. I've had this issue before on a EC2 instance that didn't have enough RAM to run a sharded bot but it would time out on the shard that the instance ran out of memory on but it would never immediately timeout like this. I've tried running it on my Mac and Windows desktop which both have 16gb of RAM and both give the same error message. Where do I even begin with debugging/solving this? Thanks.
5 Replies
d.js toolkit
d.js toolkit15mo 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!
Parogo_72
Parogo_7215mo ago
Seems like you did a breaking change then Show the code you changed or some context at least
ole113
ole113OP15mo ago
No description
Parogo_72
Parogo_7215mo ago
Can you show your sharding code?
ole113
ole113OP15mo ago
const { ShardingManager } = require("discord.js");
const { token } = require("../config.json")

const manager = new ShardingManager(`${__dirname}/main.js`, {
totalShards: "auto",
token: token,
spawnTimeout: -1,
respawn: true
});

manager.on("shardCreate", shard => {
shard.on("reconnecting", () => {
console.log(`[INFO]: Reconnecting shard [${shard.id}]`);
});
shard.on("spawn", () => {
console.log(`[INFO]: Spawned shard [${shard.id}]`);
});
shard.on("ready", () => {
console.log(`[INFO]: Shard [${shard.id}] is ready!`);
});
shard.on("death", () => {
console.log(`[INFO]: Shard [${shard.id}] died`);
});
shard.on("error", (err) => {
console.log(`[INFO]: Error in [${shard.id}]\n[ERR]: ${err}`)
shard.respawn();
})
})

manager.spawn(manager.totalShards, 15000, -1)
.then(res => {
console.log("[STARTUP]: Roast-Bot is ready!");
})
.catch(e => console.log(e));
const { ShardingManager } = require("discord.js");
const { token } = require("../config.json")

const manager = new ShardingManager(`${__dirname}/main.js`, {
totalShards: "auto",
token: token,
spawnTimeout: -1,
respawn: true
});

manager.on("shardCreate", shard => {
shard.on("reconnecting", () => {
console.log(`[INFO]: Reconnecting shard [${shard.id}]`);
});
shard.on("spawn", () => {
console.log(`[INFO]: Spawned shard [${shard.id}]`);
});
shard.on("ready", () => {
console.log(`[INFO]: Shard [${shard.id}] is ready!`);
});
shard.on("death", () => {
console.log(`[INFO]: Shard [${shard.id}] died`);
});
shard.on("error", (err) => {
console.log(`[INFO]: Error in [${shard.id}]\n[ERR]: ${err}`)
shard.respawn();
})
})

manager.spawn(manager.totalShards, 15000, -1)
.then(res => {
console.log("[STARTUP]: Roast-Bot is ready!");
})
.catch(e => console.log(e));
Want results from more Discord servers?
Add your server