mirror of
https://github.com/discordjs/discord.js.git
synced 2024-07-08 00:41:18 +12:00
fix: prevent 'undefined' debug message on intentional shard closure (#9846)
* style: prevent 'undefined' debug message on intentional shard closure addresses #9594 * refactor(WebSocketManager#destroy): improve debug messaging cleaner stacktrace format gracefully closing shards will display an appropriate debug `reason` * style: unresumable debug messaging --------- Co-authored-by: Almeida <almeidx@pm.me>
This commit is contained in:
parent
5b4a51945c
commit
0e0b85b766
|
@ -258,7 +258,7 @@ class WebSocketManager extends EventEmitter {
|
|||
* @param {number} id The shard id that disconnected
|
||||
*/
|
||||
this.client.emit(Events.ShardDisconnect, { code, reason: reasonIsDeprecated, wasClean: true }, shardId);
|
||||
this.debug(GatewayCloseCodes[code], shardId);
|
||||
this.debug(`Shard not resumable: ${code} (${GatewayCloseCodes[code] ?? CloseCodes[code]})`, shardId);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -324,9 +324,9 @@ class WebSocketManager extends EventEmitter {
|
|||
async destroy() {
|
||||
if (this.destroyed) return;
|
||||
// TODO: Make a util for getting a stack
|
||||
this.debug(`Manager was destroyed. Called by:\n${new Error().stack}`);
|
||||
this.debug(Object.assign(new Error(), { name: 'Manager was destroyed:' }).stack);
|
||||
this.destroyed = true;
|
||||
await this._ws?.destroy({ code: CloseCodes.Normal });
|
||||
await this._ws?.destroy({ code: CloseCodes.Normal, reason: 'Manager was destroyed' });
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue