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
This commit is contained in:
evanpelle
2025-07-24 12:07:58 -07:00
committed by GitHub
parent 8dedb15ce1
commit 419aef7751
+3
View File
@@ -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);