mirror of
https://github.com/ZHANGTIANYAO1/teamspeak-music-bot.git
synced 2026-10-02 04:52:50 +08:00
Add comprehensive error handling to prevent process crashes
- Global uncaughtException/unhandledRejection handlers in index.ts - FFmpeg stdout/stderr stream error handlers in player.ts - HTTP server and WebSocket server error handlers in server.ts - Safe WebSocket broadcast with try-catch in websocket.ts - Catch async errors from textMessage handler in instance.ts - Reset voiceFramesSent counter on reconnect in client.ts https://claude.ai/code/session_01EjpEsC2GCsvwbu4n3XC8EE
This commit is contained in:
6 files changed
+32
-2
No files matched your search
@@ -67,7 +67,14 @@ export function createWebServer(options: WebServerOptions): WebServer {
|
||||
});
|
||||
}
|
||||
|
||||
server.on("error", (err) => {
|
||||
logger.error({ err }, "HTTP server error");
|
||||
});
|
||||
|
||||
const wss = new WebSocketServer({ server, path: "/ws" });
|
||||
wss.on("error", (err) => {
|
||||
logger.error({ err }, "WebSocket server error");
|
||||
});
|
||||
const cleanupWs = setupWebSocket(wss, options.botManager, logger);
|
||||
|
||||
return {
|
||||
|
||||
@@ -39,7 +39,11 @@ export function setupWebSocket(
|
||||
const message = JSON.stringify(data);
|
||||
for (const client of clients) {
|
||||
if (client.readyState === WebSocket.OPEN) {
|
||||
client.send(message);
|
||||
try {
|
||||
client.send(message);
|
||||
} catch {
|
||||
clients.delete(client);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user