timotejroiko / discord.js-light

All the power of discord.js, zero caching. This library modifies discord.js's internal classes and functions in order to give you full control over its caching behaviour.
Apache License 2.0
292 stars 29 forks source link

Shard session delay #45

Closed Ortovoxx closed 3 years ago

Ortovoxx commented 3 years ago

Previously when using internal sharding with multiple sessions each one would resume after checking the session limits and waiting 5s for the identify rate limit to reset.

When resuming this behaviors is not required. I added an extension to the createShards method of the WebSocketManager class and then if keys are present in the _hotreload object it will skip waiting and handling session limits.

I have tested this with multiple shards as well as multiple shards with valid and invalid session and it works fine.

e.g. If shards 0 and 2 are valid but shard 1 is invalid it will resume shard 0 and then try to resume shard 1 which will fail and be requeued and wait 5s for a proper connection to establish before then instantly resuming shard 2