Fix draft timer display drifting due to server-client clock skew #74
Loading…
Add table
Reference in a new issue
No description provided.
Delete branch "fix/timer-clock-skew"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
data.expiresAt(server-side Unix timestamp) subtracted fromclient Date.now(). When the server clock runs ~2-3s ahead of the client (observed in production), the display was inflated by that delta.expiresAttimestamps with a client-local expiry from the server-providedtimeRemaininginteger (Date.now() + timeRemaining * 1000). The skew then cancels algebraically when the server computes credit.Sites changed
handleTimerPickStarted— fires after every pick (the main fix)handleDraftStateSync— reconnect pathuseStateinitializer in the draft room — initial page load seed from loader data (usesloaderTimerNowserver timestamp to compute remaining server-side, then re-anchors to client clock)Test plan
🤖 Generated with Claude Code
The countdown display used data.expiresAt (a server-side Unix timestamp) subtracted from client Date.now(). When the server clock is ahead of the client by ~2-3s (observed in production), the display inflated by that delta — causing 2:02 instead of 2:00 on pick start, short-crediting the chess clock increment, and the commissioner's adjust-time-bank dialog disagreeing with the visible countdown. Fix: replace all server expiresAt timestamps with a client-local expiry computed from the server-provided timeRemaining integer (Date.now() + timeRemaining * 1000). The skew then cancels algebraically: server_remaining = server_expiresAt - pickMadeAt = (client_schedule + Δ + bank*1000) - (client_pick + Δ) = client_expiresAt - client_pick ✓ Three sites updated: handleTimerPickStarted, handleDraftStateSync (reconnect), and the initial useState seed from loader data. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>