Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions src/server/GameServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -781,6 +781,13 @@ export class GameServer {
});

try {
if (ws.readyState !== WebSocket.OPEN) {
this.log.warn(`WebSocket not open, skipping start message`, {
clientID: client.clientID,
readyState: ws.readyState,
});
return;
}
ws.send(
JSON.stringify({
type: "start",
Expand All @@ -791,14 +798,10 @@ export class GameServer {
} satisfies ServerStartGameMessage),
);
} catch (error) {
// can be enabled once we can use {cause: error} in Error constructor starting with ES2022
// eslint-disable-next-line preserve-caught-error
throw new Error(
`error sending start message for game ${this.id}, ${error}`.substring(
0,
250,
),
);
this.log.error(`error sending start message for game ${this.id}`, {
clientID: client.clientID,
error: error instanceof Error ? error.message : String(error),
});
}
}

Expand Down
Loading