Discard in-flight break generation when the station changes #4
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/stale-break-race"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
_clear_stale_break() removes a finished pending break, but a break still being generated (Claude + TTS, 15-60s) can't be cancelled — it lands after the clear and becomes the new station's first break, narrating the previous station's songs. The new station's own generation task sees break_generating=True and gives up, guaranteeing the stale break plays. Same window applies to skips: an in-flight break can reference the skipped song.
Fix: a station_epoch counter bumped in _clear_stale_break() (covers genre switch, artist station, and skip — all existing call sites).
_maybe_generate_break() captures the epoch and discards its own result if the epoch moved, checking after script generation (saving the TTS cost) and again after synthesis. The next due /api/next re-triggers generation for the current station as it already does today.