From 419aef7751d6cca9aba97eb9e29c8d2660193259 Mon Sep 17 00:00:00 2001 From: evanpelle Date: Thu, 24 Jul 2025 12:07:58 -0700 Subject: [PATCH] Call remove all listeners on ws close (#1558) ## Description: After doing a memory dumb, there is a websocket handler that hadn't been cleaned up. So ensure removeAllListeners is called. ## Please complete the following: - [x] I have added screenshots for all UI updates - [x] I process any text displayed to the user through translateText() and I've added it to the en.json file - [x] I have added relevant tests to the test directory - [x] I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced - [x] I have read and accepted the CLA aggreement (only required once). ## Please put your Discord username so you can be contacted if a bug or regression is found: evan --- src/server/GameServer.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/server/GameServer.ts b/src/server/GameServer.ts index 7832e8eb0..16d894ba0 100644 --- a/src/server/GameServer.ts +++ b/src/server/GameServer.ts @@ -202,6 +202,7 @@ export class GameServer { } satisfies ServerErrorMessage), ); client.ws.close(1002, "ClientMessageSchema"); + client.ws.removeAllListeners(); return; } const clientMsg = parsed.data; @@ -259,6 +260,7 @@ export class GameServer { }); client.ws.on("error", (error: Error) => { if ((error as any).code === "WS_ERR_UNEXPECTED_RSV_1") { + client.ws.removeAllListeners(); client.ws.close(1002, "WS_ERR_UNEXPECTED_RSV_1"); } }); @@ -458,6 +460,7 @@ export class GameServer { }); if (client.ws.readyState === WebSocket.OPEN) { client.ws.close(1000, "no heartbeats received, closing connection"); + client.ws.removeAllListeners(); } } else { alive.push(client);