From 9f54a8df9c9200c7fb23be9f4c65c60c44c50ddd Mon Sep 17 00:00:00 2001 From: MARCROCK22 Date: Mon, 30 Sep 2024 02:23:36 +0000 Subject: [PATCH] fix: zombie connection --- src/websocket/discord/shard.ts | 4 ++-- src/websocket/discord/socket/custom.ts | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/websocket/discord/shard.ts b/src/websocket/discord/shard.ts index beab8e7..22e2b09 100644 --- a/src/websocket/discord/shard.ts +++ b/src/websocket/discord/shard.ts @@ -335,9 +335,9 @@ export class Shard { async close(code: number, reason: string) { clearInterval(this.heart.nodeInterval); if (!this.isOpen) { - return this.debugger?.warn(`[Shard #${this.id}] Is not open`); + return this.debugger?.warn(`[Shard #${this.id}] Is not open, reason:`, reason); } - this.debugger?.debug(`[Shard #${this.id}] Called close`); + this.debugger?.debug(`[Shard #${this.id}] Called close with reason:`, reason); this.websocket?.close(code, reason); } diff --git a/src/websocket/discord/socket/custom.ts b/src/websocket/discord/socket/custom.ts index 5c1f1cb..24f9e8d 100644 --- a/src/websocket/discord/socket/custom.ts +++ b/src/websocket/discord/socket/custom.ts @@ -234,7 +234,10 @@ export class SeyfertWebSocket { buffer.write(reason, 2); // message, close opcode this._write(buffer, 0x8); + this.socket?.end(); + + this.onclose({ code, reason }); } pong(data: string) {