Skip to content

Sharding Worker Keeps Closing - Unhandled Promise Rejection #13

@ihasTaco

Description

@ihasTaco

I have encountered an issue where the sharding worker consistently closes, leading to an unhandled promise rejection. The error message reported is as follows:

_latest.log

[ 2023-08-02T22:59:20.213Z ] | [ ERROR ] | Unhandled promise rejection: {
  "code": "ShardingReadyDied"
}

Console

[ 2023-08-02T23:07:58.758Z ] | [ ERROR ] | Unhandled promise rejection: {
  "code": "ShardingReadyDied"
}
E:\_Bots\ServerQuery - Node.js\discord\node_modules\@discordjs\ws\dist\index.js:1363
      throw new Error(
            ^

Error: Not enough sessions remaining to spawn 1 shards; only 0 remaining; resets at 2023-08-03T07:27:41.934Z
    at WebSocketManager.connect (E:\_Bots\ServerQuery - Node.js\discord\node_modules\@discordjs\ws\dist\index.js:1363:13)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async WebSocketManager.connect (E:\_Bots\ServerQuery - Node.js\discord\node_modules\discord.js\src\client\websocket\WebSocketManager.js:206:5)
    at async Client.login (E:\_Bots\ServerQuery - Node.js\discord\node_modules\discord.js\src\client\Client.js:226:7)

This issue is critical, as it interrupts the normal functioning of the bot and may lead to unexpected behavior or downtime.

Steps to Reproduce:

  • Start the bot with sharding enabled.
  • Monitor the logs for the error message.
  • Observe the sharding worker's termination.

Expected Outcome:
The sharding worker should remain active and handle requests without any unhandled promise rejections.

Actual Outcome:
The sharding worker closes unexpectedly, resulting in an unhandled promise rejection with the error code "ShardingReadyDied."

Possible Solution:
Investigate the root cause of the "ShardingReadyDied" error and implement error handling to prevent unhandled promise rejections. The solution may involve analyzing the sharding implementation, identifying the specific scenario that leads to this error, and applying the necessary fixes.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions