- Broadcast timer-bank-updated after every pick so all connected clients
immediately see the updated time bank (was only visible on next timer-pick-started)
- Capture pickMadeAt at route entry (before auth/DB overhead) and use Math.ceil
so credited seconds always match the client countdown display
- Clear picksExpiresAt on every pick so _schedulePickForSeason starts fresh
- Hold schedulingInProgress lock for full timer callback to prevent the recovery
interval from scheduling a duplicate timeout mid-pick
- Fix force-autopick route: call rescheduleTimer so the next team's clock
starts immediately instead of waiting for the old timeout to fire naturally
- Fix draft.adjust-time-bank for on-clock teams: shift picksExpiresAt by the
adjustment and reschedule, so the client countdown updates; block adjustments
that would reduce the bank to zero
- Add timer-pick-started / timer-overnight-paused / timer-bank-updated socket
events with full type definitions; replace dead timer-update event
- Fix draft-state-sync to include expiresAt for the active timer and
isOvernightPause state so reconnecting clients see accurate countdown and
pause banner immediately
- Fix room-closure countdown: capture client-side timestamp when draft completes
so countdown runs even before the loader revalidates with draftCompletedAt
- Run countdown interval at 500ms with Math.ceil to prevent skipped seconds
- Add draft-started socket handler to transition pre-draft UI without a refresh
- Fix overnight pause: canPick only blocks on commissioner pause, not overnight
pause (timer freezes but player can still pick early)
- Extract checkOvernightPause to server/overnight-pause-check.ts, breaking the
timer↔socket circular import and ensuring the timezone cache is shared and
evicted correctly across both callers
- Fix PostgreSQL varchar=uuid type mismatch in getTeamTimezone join
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Eliminates the setInterval(1s) + per-second DB write by storing picksExpiresAt
in draft_timers and using a targeted setTimeout per pick. Clients count down
locally from the expiresAt timestamp, removing server-pushed timer-update events.
Key changes:
- database/schema.ts: add picksExpiresAt and picksStartedAt to draft_timers
- server/timer.ts: full rewrite — schedulePickForSeason, rescheduleTimer,
30s recovery interval instead of 1s tick, overnight-pause resume scheduling
- server/socket.ts: new timer-pick-started / timer-overnight-paused events,
updated draft-state-sync to include expiresAt for reconnect recovery
- draft.make-pick / draft.force-manual-pick: compute actual remaining from
picksExpiresAt at pick time; call rescheduleTimer after the autodraft chain
- useDraftSocketEvents: handle new timer events, restore countdown on reconnect
- $leagueId.draft.$seasonId: client-side countdown useEffect from expiresAt
- plans/zero-downtime-scaling.md: full 4-phase scaling plan for future reference
Resolves 2351 unit tests (all passing).
https://claude.ai/code/session_019k5J6Ty7uP5HxSx6CsbiBK