mirror of
https://github.com/ZHANGTIANYAO1/teamspeak-music-bot.git
synced 2026-10-02 13:02:49 +08:00
fix: address Phase 2 review — error handlers, drain queue, prevent listener accumulation
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
a6bfd9d32c
commit
d66355a829
3 files changed
+39
-25
No files matched your search
@@ -48,6 +48,7 @@ export class TS3Connection extends EventEmitter {
|
||||
});
|
||||
this.socket.on("close", () => {
|
||||
this.connected = false;
|
||||
this.drainCommandQueue(new Error("Connection closed"));
|
||||
this.emit("close");
|
||||
});
|
||||
});
|
||||
@@ -126,6 +127,15 @@ export class TS3Connection extends EventEmitter {
|
||||
this.socket = null;
|
||||
this.connected = false;
|
||||
}
|
||||
this.drainCommandQueue(new Error("Disconnected"));
|
||||
}
|
||||
|
||||
private drainCommandQueue(error: Error): void {
|
||||
for (const pending of this.commandQueue) {
|
||||
pending.reject(error);
|
||||
}
|
||||
this.commandQueue = [];
|
||||
this.responseLines = [];
|
||||
}
|
||||
|
||||
isConnected(): boolean {
|
||||
|
||||
Reference in new issue
Block a user