mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-10 00:23:30 +01:00
* fix: Sharding bugs, silent disconnects and cleanup code * typings * fix: Destroy connecting with close code different from 1000 Per `If a client does not receive a heartbeat ack between its attempts at sending heartbeats, it should immediately terminate the connection with a non-1000 close code, reconnect, and attempt to resume.` * misc: Wait x ms before reconnecting Per https://discordapp.com/developers/docs/topics/gateway#resuming * docs * nit: docs * misc: Prevent multiple calls to WebSocketManager#destroy * fix: Implement destroying if you reset the token * misc: Clear the WS packet queue on WebSocketShard#destroy You can't send those packets anywhere anymore, so no point in keeping them * fix: Handle session limits when reconnecting a full shard, cleanup * misc: No need to create a new shard instance * fix: closeSequence being null, thus emitting null on Client#resumed * misc: Remove GUILD_SYNC Gateway handler and add missing dot to string * misc: Close WS with code 4000 if we didn't get a heartbeat in time As said in the Discord API server * fix: Handle ready emitting in onPacket Doesn't allow broken packets * misc: Close the connection if Discord asks for a reconnect Prevents double triggers * testing: Prevent multiple reconnect attempts on a shard Should fix some issues some people have had. * fix: Prevent multiple reconnect calls on the shard, re-use conn to identify, remove reconnect function Note: Closing the WS with 1000 makes the session invalid * misc: Forgot to remove 2 unneeded setters * docs: Wrong param docstring for WebSocketShard#destroy * misc: Set status to reconnecting after destroying * misc: Close connection with code 1000 on session invalidated Allows us to cleanup the shard and do a full reconnect Also remove identify wait delay, not used anywhere * fix: Fix zlib crash on node And with that, the PR is done! * misc: Implement a reconnect queue And that is all there was to be done in this PR. Shards now queue up for a reconnect * nit: Debug the queue after destroying * docs: Make the invalidated event clearer * lint: I'm good at my job * docs * docs: Make description for isReconnectingShards accurate *can I stop finding issues, this PR is meant to be done* * misc: Remove shard from bind params * misc: Code re-ordering and cleanup Resumes do not need to be queued up, as they do not count to the identify limit, and after some testing, they don't have the 5 second delay required, like in identify * fix: Issues with token regeneration and shards not properly handling them We close the ws connection with code 1000 if we get an invalid session payload, that way we can queue the reconnects and handle any issues * misc: Remove useless delays on session invalidated They get handled by the rest of the code already * lint * misc: reset the sequence on Shard#destroy This especially is a problem if you need to re-identify, as the sequence doesn't get set to the current one, causing the sequence to be wrong * fix: GitHub rebase and minor tweak * Implement a 15 second timeout if shards don't connect till then Should prevent shards that never reconnect * revert: Make WebSocketShard#send and WebSocketManager#broadcast public * typings: Set type to void instead of undefined * docs: Requested Changes