Skip to content

fix: all shards spawning on shard 0 with sharding manager #10814

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

Merged
merged 1 commit into from
Mar 22, 2025

Conversation

almeidx
Copy link
Member

@almeidx almeidx commented Mar 22, 2025

process.env.SHARDS only has the shard id (not an array). This meant that we were passing shardIds: 0 to WebSocketManager, which fails this the following if statement, making /ws fetch get all shards and start them on the current process.

public async getShardIds(force = false): Promise<number[]> {
if (this.shardIds && !force) {

image

Copy link

vercel bot commented Mar 22, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

2 Skipped Deployments
Name Status Preview Comments Updated (UTC)
discord-js ⬜️ Ignored (Inspect) Visit Preview Mar 22, 2025 5:47pm
discord-js-guide ⬜️ Ignored (Inspect) Visit Preview Mar 22, 2025 5:47pm

@vladfrangu
Copy link
Member

Doesn't this get set to 0,1,2 when having multiple shards per process?

@Qjuh
Copy link
Member

Qjuh commented Mar 22, 2025

Current ShardingManager has no notion of multiple shards per process. But I agree that it should be possible to pass both array of ids and plain number to it, same way it was possible in v14. So instead of this fix it should be added as conversion to array if typeof is number

@almeidx almeidx force-pushed the fix/sharding-manager-shards branch from 9170dca to e4fadea Compare March 22, 2025 17:47
@Qjuh
Copy link
Member

Qjuh commented Mar 22, 2025

This is not an issue in v14, as it‘s correctly converted to an array there. So nothing to backport.

@github-project-automation github-project-automation bot moved this from Todo to Review Approved in discord.js Mar 22, 2025
@kodiakhq kodiakhq bot merged commit 73f2ef9 into main Mar 22, 2025
8 checks passed
@kodiakhq kodiakhq bot deleted the fix/sharding-manager-shards branch March 22, 2025 20:17
@github-project-automation github-project-automation bot moved this from Review Approved to Done in discord.js Mar 22, 2025
@sdanialraza sdanialraza added this to the discord.js 15.0.0 milestone Mar 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants