ihasTaco / ServerQuery

A Discord Bot that queries game servers
Mozilla Public License 2.0
0 stars 0 forks source link

Sharding Worker Keeps Closing - Unhandled Promise Rejection #13

Open ihasTaco opened 1 year ago

ihasTaco commented 1 year ago

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:

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.

ihasTaco commented 1 year ago

Ok I have no way to test if the new develop build will fix this issue, but I am running out of time before my vacation. Once I am back, I have a few projects I need to do, and then I will write some tests to see if it works correctly

But in the meantime, I have disabled sharding for bots that are under 2500 guilds, so technically the issue is fixed but its only a patch up job.