brackt/server
Chris Parsons b81089879c
Fix while_on autodraft stalling between chain bursts, fixes #190 (#222)
The chain (checkAndTriggerNextAutodraft) picks consecutive while_on teams
immediately after a pick, but is capped at totalTeams iterations. Once the
cap is hit, the next while_on team had to wait for the full timer countdown
before their pick fired — which users experienced as autodraft intermittently
not working.

Root cause fix: the timer loop now detects while_on mode and triggers the
pick immediately (≤1 s) regardless of time remaining, bypassing the
countdown. A timer-update with timeRemaining:0 is emitted first so clients
don't see a frozen timer. If the chain already handled the pick, executeAutoPick
returns "Pick already made" and the timer moves on harmlessly.

Additional fixes:
- Add timerTickRunning guard so concurrent setInterval ticks (when a chain
  takes >1 s) don't race on the same pick slot
- Use onConflictDoNothing on the draft pick INSERT in executeAutoPick so a
  DB unique-constraint collision is treated as "Pick already made" rather
  than pausing the draft
- Cache draftSlots per season in the timer loop (slots never change during
  an active draft) — eliminates one DB query per tick
- currentPickNumber || 1 → ?? 1

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-24 19:09:38 -07:00
..
__tests__ Claude/redesign autodraft queue c4 kp r (#40) 2026-02-27 22:16:26 -08:00
app.ts Fix postgres connection pool leak in development (#195) 2026-03-21 09:57:53 -07:00
logger.ts Replace console.* with structured logger, fix no-inferrable-types (closes #98) (#199) 2026-03-21 13:41:39 -07:00
snapshots.ts Replace console.* with structured logger, fix no-inferrable-types (closes #98) (#199) 2026-03-21 13:41:39 -07:00
socket.d.ts feat: integrate Socket.IO server with HTTP server and draft room functionality 2025-10-16 18:15:04 -07:00
socket.ts Replace console.* with structured logger, fix no-inferrable-types (closes #98) (#199) 2026-03-21 13:41:39 -07:00
timer.ts Fix while_on autodraft stalling between chain bursts, fixes #190 (#222) 2026-03-24 19:09:38 -07:00
types.d.ts Add oxlint linting setup with zero errors (#194) 2026-03-21 09:44:05 -07:00
virtual-modules.d.ts feat: integrate Socket.IO server with HTTP server and draft room functionality 2025-10-16 18:15:04 -07:00