Repository navigation
fix(autoplay): replenish queue on exhaustion + suppress recovery on stale snapshot - #691
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Warning Rate limit exceeded
Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 11 minutes and 25 seconds. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (9)
✨ Finishing Touches🧪 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 |
…tale snapshot Root causes of autoplay regression: 1. Queue exhaustion during autoplay: emptyQueue event marked as intentional stop but didn't attempt replenishment. Now attempts replenish when autoplay is enabled and currentTrack exists. 2. Skip on last track → disconnect → watchdog rejoin: When queue emptied after skip/finish, no protection prevented watchdog orphan recovery from immediately rejecting. Added setReplenishSuppressed(35s) to prevent recovery until idle timeout fires. 3. Watchdog restores stale snapshot: restoreSnapshot had skipCurrentTrack but upcomingTracks[0] could still be the just-played song. Added clearSnapshotIfStale() to delete snapshot when only currentTrack exists (queue was drained). Changes: - lifecycleHandlers.ts: emptyQueue now calls replenishQueue instead of markIntentionalStop when autoplay is enabled - trackHandlers.ts: added setReplenishSuppressed(35s) + clearSnapshotIfStale() when queue becomes empty after skip/finish - sessionSnapshots.ts: added clearSnapshotIfStale() helper to clean stale snapshots - replenisher.ts: improved debug logging for exhausted candidate pool - lifecycleHandlers.spec.ts: added tests for emptyQueue autoplay replenishment - trackHandlers.spec.ts: added mocks for replenishSuppressionStore and clearSnapshotIfStale Integration: No behavior changes outside the 3 symptoms. All existing tests green. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
e6f2a41 to
4609f9b
Compare
- Create queueExhaustion.ts with shared handleQueueExhaustion function - Refactor handlePlayerFinish and handlePlayerSkip to use shared handler - Add unit tests for queueExhaustion module - Reduces code duplication between finish and skip event handlers - Maintains all existing behavior with 2735 tests passing
Adds 8 tests for redis error swallowing, missing key, clearStaleIfStale no-ops, restoreSnapshot guards. Coverage 78.20% → 91.02% lines / 70.49% → 83.60% branches.
|
…tale snapshot (#691) * fix(autoplay): replenish queue on exhaustion + suppress recovery on stale snapshot Root causes of autoplay regression: 1. Queue exhaustion during autoplay: emptyQueue event marked as intentional stop but didn't attempt replenishment. Now attempts replenish when autoplay is enabled and currentTrack exists. 2. Skip on last track → disconnect → watchdog rejoin: When queue emptied after skip/finish, no protection prevented watchdog orphan recovery from immediately rejecting. Added setReplenishSuppressed(35s) to prevent recovery until idle timeout fires. 3. Watchdog restores stale snapshot: restoreSnapshot had skipCurrentTrack but upcomingTracks[0] could still be the just-played song. Added clearSnapshotIfStale() to delete snapshot when only currentTrack exists (queue was drained). Changes: - lifecycleHandlers.ts: emptyQueue now calls replenishQueue instead of markIntentionalStop when autoplay is enabled - trackHandlers.ts: added setReplenishSuppressed(35s) + clearSnapshotIfStale() when queue becomes empty after skip/finish - sessionSnapshots.ts: added clearSnapshotIfStale() helper to clean stale snapshots - replenisher.ts: improved debug logging for exhausted candidate pool - lifecycleHandlers.spec.ts: added tests for emptyQueue autoplay replenishment - trackHandlers.spec.ts: added mocks for replenishSuppressionStore and clearSnapshotIfStale Integration: No behavior changes outside the 3 symptoms. All existing tests green. * refactor: extract duplicate queue exhaustion logic into shared handler - Create queueExhaustion.ts with shared handleQueueExhaustion function - Refactor handlePlayerFinish and handlePlayerSkip to use shared handler - Add unit tests for queueExhaustion module - Reduces code duplication between finish and skip event handlers - Maintains all existing behavior with 2735 tests passing * test(autoplay): cover sessionSnapshots error paths and edge cases Adds 8 tests for redis error swallowing, missing key, clearStaleIfStale no-ops, restoreSnapshot guards. Coverage 78.20% → 91.02% lines / 70.49% → 83.60% branches. --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>


Summary
Fixed critical autoplay regression affecting three symptoms:
Root Causes
emptyQueueevent marked stop but didn't replenish during autoplayskipCurrentTrackbut upcomingTracks[0] could still be the just-played songChanges
emptyQueuenow callsreplenishQueuewhen autoplay enabled + currentTrack existssetReplenishSuppressed(35s)+clearSnapshotIfStale()when queue becomes emptyclearSnapshotIfStale()helper to delete stale snapshots (drained queue)Test Plan
Fixes: Queue stall, unexpected disconnect, unwanted rejoin with stale track
🤖 Generated with Claude Code