mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-21 09:30:45 +00:00
Fix public lobby timer stuck due to IPC race condition
This commit is contained in:
@@ -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(),
|
||||
|
||||
Reference in New Issue
Block a user