mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-11 00:53:31 +01:00
src: fix up WebSocketShard errors (#3722)
* src: Fix up WebSocketShard errors * typings: Forgot to update * src: Forgot debug variable * src: Fix issue Bella found If the WS was not connected when the HELLO timeout passes (CONNECTING, etc), the shard would get stuck due to never rejecting the WebSocketShard#connect Promise with the DESTROYED event
This commit is contained in:
@@ -18,7 +18,7 @@ const BeforeReadyWhitelist = [
|
||||
WSEvents.GUILD_MEMBER_REMOVE,
|
||||
];
|
||||
|
||||
const UNRECOVERABLE_CLOSE_CODES = [4004, 4010, 4011];
|
||||
const UNRECOVERABLE_CLOSE_CODES = Object.keys(WSCodes).slice(1);
|
||||
const UNRESUMABLE_CLOSE_CODES = [1000, 4006, 4007];
|
||||
|
||||
/**
|
||||
@@ -235,7 +235,7 @@ class WebSocketManager extends EventEmitter {
|
||||
this.debug(`Session ID is present, attempting an immediate reconnect...`, shard);
|
||||
this.reconnect(true);
|
||||
} else {
|
||||
shard.destroy(undefined, true);
|
||||
shard.destroy({ reset: true, emit: false, log: false });
|
||||
this.reconnect();
|
||||
}
|
||||
});
|
||||
@@ -245,8 +245,6 @@ class WebSocketManager extends EventEmitter {
|
||||
});
|
||||
|
||||
shard.on(ShardEvents.DESTROYED, () => {
|
||||
shard._cleanupConnection();
|
||||
|
||||
this.debug('Shard was destroyed but no WebSocket connection was present! Reconnecting...', shard);
|
||||
|
||||
this.client.emit(Events.SHARD_RECONNECTING, shard.id);
|
||||
@@ -342,7 +340,7 @@ class WebSocketManager extends EventEmitter {
|
||||
this.debug(`Manager was destroyed. Called by:\n${new Error('MANAGER_DESTROYED').stack}`);
|
||||
this.destroyed = true;
|
||||
this.shardQueue.clear();
|
||||
for (const shard of this.shards.values()) shard.destroy(1000, true);
|
||||
for (const shard of this.shards.values()) shard.destroy({ closeCode: 1000, reset: true, emit: false });
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user