Skip to content

fix: anchor client clocks to server snapshots - #15

Merged
wjc2821296948 merged 3 commits into
Low-Rate:mainfrom
lijiashu1:fix/client-clock-drift
Oct 20, 2026
Merged

wjc2821296948 merged 3 commits into
Low-Rate:mainfrom
lijiashu1:fix/client-clock-drift

Conversation

@lijiashu1

@lijiashu1 lijiashu1 commented Oct 19, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Treat the remaining-time values returned by the server as a clock snapshot and measure client-side elapsed time from when that snapshot is received.
  • Avoid subtracting elapsed time twice after restoring a game or fetching a session, while leaving the server-provided turnStartedAt unchanged.
  • Continue updating the displayed countdown locally between server events.

Validation

  • Reviewed the timer calculation and updated the client implementation.
  • Automated tests were not run in this workflow.

@wjc2821296948 wjc2821296948 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This change reintroduces the clock double-decrement bug. The server returns sessionState(session) using clockedState(session), which has already subtracted elapsed time from totalRemainingMs and moveRemainingMs while leaving the original turnStartedAt in the state. Preserving that timestamp on the client makes displayedClock() subtract the same elapsed interval again. The client snapshot needs a baseline aligned with the already-clocked remaining values, or the server response must return remaining values/timestamp from the same instant.

Comment thread app.js Outdated
@lijiashu1 lijiashu1 changed the title fix: preserve authoritative turn clock in client fix: anchor client clocks to server snapshots Oct 20, 2026
@wjc2821296948
wjc2821296948 merged commit 066065a into Low-Rate:main Oct 20, 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.

3 participants