Merge pull request #1 from Moepchi/fix/pr-4-review-bugs

Fix 8 correctness bugs found in review of TeaSpeak/GTS + multi-join PR
This commit is contained in:
Nico B. authored and GitHub committed 2026-09-06 01:20:59 +02:00
commit a118c0f58e
4 files changed
+93 -20

No files matched your search

+18 -2
View File
@@ -796,9 +796,25 @@ export class Ts3Connection {
async disconnect(message = ""): Promise<void> {
if (this.child && !this.child.killed) {
const child = this.child;
const sanitized = message.replace(/[\r\n]+/g, " ").trim();
this.child.stdin.write(`disconnect ${sanitized}\n`);
this.child.stdin.end();
child.stdin.write(`disconnect ${sanitized}\n`);
child.stdin.end();
// Wait for the connector process to actually exit before returning, so a
// caller that immediately reconnects (index.ts's "connect" handler) never
// spawns a replacement while this one is still shutting down - two
// connector processes would otherwise briefly hold the same audio/socket
// resources. Fall back to a hard kill if it doesn't exit on its own.
await new Promise<void>((resolve) => {
const timeout = setTimeout(() => {
child.kill();
resolve();
}, 3000);
child.once("exit", () => {
clearTimeout(timeout);
resolve();
});
});
}
this.listeners.clear();
}