Skip to content

Hold the player's first client/state until the clock syncs - #236

Merged
maximmaxim345 merged 1 commit into
mainfrom
fix/hold-client-state-until-sync
Nov 6, 2026
Merged

maximmaxim345 merged 1 commit into
mainfrom
fix/hold-client-state-until-sync

Conversation

@maximmaxim345

Copy link
Copy Markdown
Member

What does this implement/fix?

The player sent its first client/state with available: false until its clock synced. A server following the updated spec ungroups a client that opens with available: false, so the player would leave its group on every reconnect.

The player now holds back its first client/state until its clock syncs and always reports available: true. Clients without the player role still send it right away.

Related issue or spec PR (if applicable):

Types of changes

  • Bugfix (non-breaking change which fixes an issue): bugfix
  • New feature (non-breaking change which adds functionality): new-feature
  • Enhancement to an existing feature: enhancement
  • Breaking change (changes the public API or the protocol in a way that is not backwards compatible): breaking-change
  • Refactor (no behavior change): refactor
  • Documentation only: documentation
  • Maintenance / chore: maintenance
  • CI / workflow change: ci
  • Dependencies bump: dependencies

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are recorded for the change that defers player state reporting until clock synchronization.

No open issues 🎉

What changed in this PR

This PR prevents players from leaving their group on reconnect by withholding client/state until clock synchronization, rather than initially reporting available: false.

Changes:

  • Delay player state updates until the clock synchronizes, then report available: true.
  • Preserve immediate state updates for clients without the player role.
  • Update unit tests and fixtures to cover deferred state reporting and synchronized activation.
File Description
tests/​unit/​protocol-handler.test.ts Verify deferred player state, pending volume changes, and immediate non-player state.
tests/​unit/​core.test.ts Synchronize the clock before activation in state-forwarding tests.
tests/​unit/​core-encryption.test.ts Synchronize the clock in encrypted state-reporting tests.
src/​core/​protocol-handler.ts Gate player state updates on clock synchronization and report availability as true.

Review effort: Balanced

@maximmaxim345
maximmaxim345 merged commit 7cda8e0 into main Nov 6, 2026
4 checks passed
@maximmaxim345
maximmaxim345 deleted the fix/hold-client-state-until-sync branch November 6, 2026 07:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix Fixes a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants