Fix draft timer display drifting due to server-client clock skew #74

Merged
chrisp merged 2 commits from fix/timer-clock-skew into main 2026-06-06 07:30:45 +00:00
Showing only changes of commit a4317815f7 - Show all commits

View file

@ -508,7 +508,7 @@ export default function DraftRoom() {
// loaderTimerNow is server-side Date.now() — subtract from server expiresAt to get ms remaining
// without skew, then re-anchor to client clock.
const active = timers.find((t) => t.picksExpiresAt && t.picksExpiresAt.getTime() > loaderTimerNow);
if (!active) return null;
if (!active?.picksExpiresAt) return null;
const secondsRemaining = Math.ceil((active.picksExpiresAt.getTime() - loaderTimerNow) / 1000);
return { teamId: active.teamId, expiresAt: Date.now() + secondsRemaining * 1000 };
});