Repository navigation
fix(bot): serialize autoplay replenish per guild, write redis on add - #565
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Caution Review failedPull request was closed or merged during review 📝 WalkthroughWalkthroughTest mocks extended with Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Suggested labels
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|



Root Causes Fixed
Full analysis is in
.claude/plans/autoplay-dedup-fix-2026-04-11.md.1. Race condition (CRITICAL) — per-guild mutex
replenishQueuewas called concurrently fromplayerStart,playerFinish, andplayerSkip. Each call built its own localexcludedUrls/excludedKeyssets at call time. If two calls overlapped by even a few milliseconds, both would see the same exclusion sets and independently select the same track.Fix: Module-level
replenishLocks: Map<string, Promise<void>>. EachreplenishQueuecall for a guild chains onto the previous call's promise, ensuring serialization.2. Just-added tracks not in Redis for concurrent calls
Previously, autoplay tracks were only written to Redis history when they finished playing. The concurrent call from the next event would not find them in Redis exclusions.
Fix:
addSelectedTracksnow immediately writes each added track to Redis history (fire-and-forgetvoid). The next replenish call (milliseconds later) finds them in Redis.3. History lookback too short
Changed
getTrackHistory(guild.id, 20)→getTrackHistory(guild.id, 50). Covers ~3h sessions.Observability
warnLogwhen Redis history is empty (potential Redis issue)debugLogwith exclusion set sizes after build (visible in debug mode)1905 tests, 0 failures.
Summary by CodeRabbit