diff --git a/src/server/MasterLobbyService.ts b/src/server/MasterLobbyService.ts index dee30ad04..9285b8a91 100644 --- a/src/server/MasterLobbyService.ts +++ b/src/server/MasterLobbyService.ts @@ -135,12 +135,13 @@ export class MasterLobbyService { for (const type of Object.keys(lobbiesByType) as PublicGameType[]) { const lobbies = lobbiesByType[type]; - if (lobbies.length >= 2) { - continue; - } + + // Always ensure the next lobby has a timer, even if we already have 2+ + // lobbies. This prevents a race where two lobbies are created before + // either receives a startsAt (IPC round-trip delay), leaving both stuck + // without a countdown. const nextLobby = lobbies[0]; if (nextLobby && nextLobby.startsAt === undefined) { - // The previous game has started, so we need to set the timer on the next game. this.sendMessageToWorker({ type: "updateLobby", gameID: nextLobby.gameID, @@ -148,6 +149,10 @@ export class MasterLobbyService { }); } + if (lobbies.length >= 2) { + continue; + } + this.sendMessageToWorker({ type: "createGame", gameID: generateID(),