diff --git a/Client/origin-client/autoloads/CustomLobby.gd b/Client/origin-client/autoloads/CustomLobby.gd index 4d7413c..06a7d5e 100644 --- a/Client/origin-client/autoloads/CustomLobby.gd +++ b/Client/origin-client/autoloads/CustomLobby.gd @@ -168,7 +168,12 @@ func leave(on_done: Callable = Callable()) -> void: lobby_left.emit() if on_done.is_valid(): on_done.call(), func(code: String, msg: String) -> void: - print("[CustomLobby] ERR leave ", code, " ", msg)) + print("[CustomLobby] ERR leave ", code, " ", msg) + if code == "LOBBY_NOT_FOUND": + # Treat as stale local lobby state and recover UX. + clear_state() + lobby_left.emit() + if on_done.is_valid(): on_done.call()) ## Mark the caller as ready with their final deck and first-turn preference. diff --git a/Server/src/SOR.Game/Handlers/GameLeaveCustomLobbyHandler.cs b/Server/src/SOR.Game/Handlers/GameLeaveCustomLobbyHandler.cs index 5081332..2d392e1 100644 --- a/Server/src/SOR.Game/Handlers/GameLeaveCustomLobbyHandler.cs +++ b/Server/src/SOR.Game/Handlers/GameLeaveCustomLobbyHandler.cs @@ -45,8 +45,13 @@ internal sealed class GameLeaveCustomLobbyHandler : GameHandlerBase, IMessageHan var req = _serializer.DeserializePayload(message.Payload); var accountId = Guid.Parse(connection.UserId); - var lobby = await _gameDb.CustomLobbies.FindAsync([req.LobbyId], ct) - ?? throw new GameException("LOBBY_NOT_FOUND"); + var lobby = await _gameDb.CustomLobbies.FindAsync([req.LobbyId], ct); + if (lobby is null) + { + // Idempotent leave: stale client lobby IDs should not hard-fail. + return ServerMessage.Reply("game.custom.leave.ack", message.Seq, + new LeaveCustomLobbyResponse(LobbyId: req.LobbyId)); + } // If already resolved (game started or lobby cancelled), return success silently. // Player should use game.concede for an in-progress game.