Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shard 0's process exited before its Client became ready. #5364

Closed
MaximKing1 opened this issue Mar 1, 2021 · 10 comments
Closed

Shard 0's process exited before its Client became ready. #5364

MaximKing1 opened this issue Mar 1, 2021 · 10 comments

Comments

@MaximKing1
Copy link

MaximKing1 commented Mar 1, 2021

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
@veronancy
Copy link

similar error here

@vyPal
Copy link

vyPal commented Mar 4, 2021

Started getting this also

@thebigwolfy
Copy link

i have the error

@SpaceEEC
Copy link
Member

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.

@phamleduy04
Copy link

I also got this error on master branch but not latest version!

@tonestrike
Copy link

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.

@kyranet
Copy link
Member

kyranet commented Dec 3, 2021

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.

@vyPal
Copy link

vyPal commented Dec 3, 2021

I have absolutely no clue, but I'll try it when I have some free time and notify you with the results

@7ijme
Copy link

7ijme commented Jun 20, 2022

Does anyone know how to fix this?

@didinele
Copy link
Member

didinele commented Jul 6, 2024

discord.js version: v12.15.1

If this issue continues to exist, please open a new one.

@didinele didinele closed this as not planned Won't fix, can't repro, duplicate, stale Jul 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests