mirror of
https://github.com/discordjs/discord.js.git
synced 2026-09-17 08:47:27 +00:00
refactor(WebSocketShard): clear ws session only when explicitly reconnecting (#11601)
* refactor(WebSocketShard): clear ws session when explicitly reconnecting * fix(ws): check for .resuming code * fix(ws): actually correct clear logic * refactor: flip Co-authored-by: Almeida <github@almeidx.dev> --------- Co-authored-by: Almeida <github@almeidx.dev> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
This commit is contained in:
co-authored by
Almeida
kodiakhq[bot]
parent
5f6cbf111e
commit
a4116036be
@@ -379,6 +379,12 @@ export class WebSocketManager extends AsyncEventEmitter<ManagerShardEventsMap> i
|
||||
this.#token = token;
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroys all shards
|
||||
*
|
||||
* @remarks
|
||||
* To keep the shard(s) resumable, use the {@link CloseCodes.Resuming} code.
|
||||
*/
|
||||
public destroy(options?: Omit<WebSocketShardDestroyOptions, 'recover'>) {
|
||||
return this.strategy.destroy(options);
|
||||
}
|
||||
|
||||
@@ -360,7 +360,10 @@ export class WebSocketShard extends AsyncEventEmitter<WebSocketShardEventsMap> {
|
||||
this.failedToConnectDueToNetworkError = false;
|
||||
|
||||
// Clear session state if applicable
|
||||
if (options.recover !== WebSocketShardDestroyRecovery.Resume) {
|
||||
if (
|
||||
(options.recover !== WebSocketShardDestroyRecovery.Resume && options.code !== CloseCodes.Resuming) ||
|
||||
options.code === CloseCodes.Normal
|
||||
) {
|
||||
await this.strategy.updateSessionInfo(this.id, null);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user