From 18f4a117abfebc45e9dc693c69372a58fce99f14 Mon Sep 17 00:00:00 2001 From: lebaudantoine Date: Mon, 24 Mar 2025 18:13:24 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=A9=B9(backend)=20invert=20operation=20or?= =?UTF-8?q?der=20in=20participant=20handling?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Invert operation sequence to first notify people in room before setting participant in cache. Fixes infinite loop issue caused by 3s cache timeout for waiting participants when requests take too long. Problem only occurred when notifications were delayed, as faster notification delivery masked the race condition. --- src/backend/core/services/lobby.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/backend/core/services/lobby.py b/src/backend/core/services/lobby.py index 2ddaf80d..36f2fb35 100644 --- a/src/backend/core/services/lobby.py +++ b/src/backend/core/services/lobby.py @@ -221,6 +221,12 @@ class LobbyService: color=color, ) + try: + self.notify_participants(room_id=room_id) + except LobbyNotificationError: + # If room not created yet, there is no participants to notify + pass + cache_key = self._get_cache_key(room_id, participant_id) cache.set( cache_key, @@ -228,12 +234,6 @@ class LobbyService: timeout=settings.LOBBY_WAITING_TIMEOUT, ) - try: - self.notify_participants(room_id=room_id) - except LobbyNotificationError: - # If room not created yet, there is no participants to notify - pass - return participant def _get_participant(