mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-21 14:50:44 +00:00
fix: add readyState check before endTurn broadcast (#3879)
## Description: Guard `ws.send()` in `endTurn()` with a `readyState === OPEN` check to prevent sending messages to WebSocket connections that have already closed. Without this guard, broadcasting to a client whose connection closed between ticks can throw an exception and crash the game loop. ## 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 ## Please put your Discord username so you can be contacted if a bug or regression is found: barfires
This commit is contained in:
@@ -823,7 +823,9 @@ export class GameServer {
|
||||
turn: pastTurn,
|
||||
} satisfies ServerTurnMessage);
|
||||
this.activeClients.forEach((c) => {
|
||||
c.ws.send(msg);
|
||||
if (c.ws.readyState === c.ws.OPEN) {
|
||||
c.ws.send(msg);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user