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> |
||
|---|---|---|
| .. | ||
| __tests__ | ||
| app.ts | ||
| logger.ts | ||
| snapshots.ts | ||
| socket.d.ts | ||
| socket.ts | ||
| timer.ts | ||
| types.d.ts | ||
| virtual-modules.d.ts | ||