Skip to content

fix: register socket listeners before awaiting first connection#2762

Merged
veloce merged 1 commit intolichess-org:mainfrom
lacostej:fix/socket-listener-race-conditions
Mar 16, 2026
Merged

fix: register socket listeners before awaiting first connection#2762
veloce merged 1 commit intolichess-org:mainfrom
lacostej:fix/socket-listener-race-conditions

Conversation

@lacostej
Copy link
Copy Markdown
Contributor

@lacostej lacostej commented Mar 14, 2026

Summary

While investigating #2750 (fixed in #2756), we found the same race condition pattern in three other places: socket event listeners registered after await _socketClient.firstConnection, meaning reconnection events firing during the initial connection gap could be missed.

Affected controllers:

  • BroadcastRoundControllerconnectedStream.listen() moved before await firstConnection
  • BroadcastAnalysisController — same pattern
  • LiveTvChannels — both connectedStream.listen() and stream.listen() moved before await firstConnection

The fix is the same in all cases: register listeners before awaiting, so no events are lost.

Test plan

  • Open a broadcast round — should load and update normally
  • Open broadcast analysis — should load and update normally
  • Open TV channels — should load and update normally
  • Verify reconnection after brief connectivity loss still triggers sync in all three views

Move connectedStream and stream listener registration before
`await _socketClient.firstConnection` in broadcast and TV controllers
to avoid missing reconnection events during the initial connection.

Similar pattern to the race condition fixed in RetroController (lichess-org#2756).
@veloce veloce merged commit 0086651 into lichess-org:main Mar 16, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants