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

broadcastEval throws SHARDING_IN_PROCESS error even though it should execute no matter how many shards are open #5372

Closed
nobu-sh opened this issue Mar 5, 2021 · 4 comments

Comments

@nobu-sh
Copy link

nobu-sh commented Mar 5, 2021

broadcastEval throws a SHARDING_IN_PROCESS error when trying to use during shards being spawned however this was not an issue in older versions of the library

shard.js

const { ShardingManager } = require('discord.js')
const constants = require('./constants')

const manager = new ShardingManager('./src/index.js', {
  token: process.env.TOKEN,
  totalShards: constants.totalShards,
})

manager.spawn(process.env.TOTAL_SHARDS, 10000, -1)

index.js

const { Client } = require('discord.js')
const client = new Client()

client.on('ready', () => {
   client.shard.broadcastEval(`
      this.user.setActivity("Bot Starting Up...", { type: "PLAYING" }) 
   `).then().catch()
})

client.login(process.env.TOKEN)

Further details:

  • discord.js version: ^12.5.1
  • Node.js version: 14.15.4
  • Operating system: Windows 10
@iCrawl
Copy link
Member

iCrawl commented Mar 5, 2021

Define:

an issue in older versions of the library

If you upgraded from v11 to v12 breaking changes are to be expected.

@iCrawl
Copy link
Member

iCrawl commented Mar 5, 2021

Ref: #5222

@MattIPv4
Copy link
Contributor

Working around this is relatively easy if you have a need to run broadcastEval on your shards whilst some are spawning -- just iterate over each shard and call broadcastEval with the shard number, catching the error thrown for any shards that are currently being spawned.

I would not consider SHARDING_IN_PROCESS being thrown to be a bug here, you are trying to call broadcastEval which is designed by default to broadcast to all shards, but not all shards are available so you are getting the appropriate error back.

@kyranet
Copy link
Member

kyranet commented Jun 15, 2021

Closing as it's resolved in the master branch with #5222.

@kyranet kyranet closed this as completed Jun 15, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 1, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants