mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-21 13:30:43 +00:00
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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user