fix: zombie connection

This commit is contained in:
MARCROCK22 2024-09-30 02:23:36 +00:00
parent dd8fbd2789
commit 9f54a8df9c
2 changed files with 5 additions and 2 deletions

View File

@ -335,9 +335,9 @@ export class Shard {
async close(code: number, reason: string) { async close(code: number, reason: string) {
clearInterval(this.heart.nodeInterval); clearInterval(this.heart.nodeInterval);
if (!this.isOpen) { 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); this.websocket?.close(code, reason);
} }

View File

@ -234,7 +234,10 @@ export class SeyfertWebSocket {
buffer.write(reason, 2); buffer.write(reason, 2);
// message, close opcode // message, close opcode
this._write(buffer, 0x8); this._write(buffer, 0x8);
this.socket?.end(); this.socket?.end();
this.onclose({ code, reason });
} }
pong(data: string) { pong(data: string) {