fix: MA+YTMusic playback regression β restore timeout tolerance and add title verification (#345)#497
Conversation
β¦dd title verification (mholzi#345) - Restore return True on MA playback timeout (reverts mholzi#418 regression) - Replace "any title change" with expected title substring match to prevent race condition - Remove hardcoded 2s setTimeout on Next Round button, wait for server phase change - Add WebSocket guard to prevent double connections (InvalidStateError fix) - Update and add unit tests for title matching and timeout behavior Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Code Review
This pull request improves the reliability of song playback confirmation in the media_player service by implementing case-insensitive substring matching for titles and preventing unnecessary retries during buffering. In the frontend, it adds guards against duplicate WebSocket connections and refactors the "Next Round" button logic to wait for server confirmation rather than using a fixed timeout. Review feedback highlights a potential AttributeError in the Python service if the song title is explicitly None and notes that the frontend resetNextRoundPending function needs to explicitly re-enable the UI button and reset its text to avoid it being stuck in a "Loading" state.
|
Note: The two failing checks (Hassfest Validation, Lint) are pre-existing on
|
- Use `song.get("title") or ""` to handle explicit None values (prevents
AttributeError on .lower())
- Reset button visual state (disabled + text) in resetNextRoundPending()
as defensive measure β updateRevealView() already handles this on each
REVEAL phase, but explicit reset ensures consistency
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Summary
Fixes a regression introduced by #418 that reverted the MA+YTMusic playback fix from #345.
return Trueβreturn Falseon MA playback timeout, causingstart_round()to retry with a new song. Sinceblocking=False, the previous song is still buffering β the Sonos receives 3-4 songs in rapid succession.checkGameStatus()(async) andinitAll()could both open a WebSocket simultaneously, causingInvalidStateError: Still in CONNECTING stateand dropping the connection.Changes
services/media_player.pyreturn Trueon timeout β MA+YTMusic can take >8s to buffer, don't skip the songtitle_changed(any change) withtitle_matches(expected title substring, case-insensitive) to prevent race condition where a previous slow song is falsely confirmedwww/js/player-game.jssetTimeout(2000)that re-enabled the Next Round buttonresetNextRoundPending()β called on actual phase change insteadwww/js/player-core.jsresetNextRoundPending()when phase transitions to PLAYINGconnectWithSession()andconnectWebSocket()to prevent double connectionswww/js/player.bundle.min.jsnpx esbuildwith above JS changestests/unit/test_media_player.pytest_ma_returns_true_even_on_timeout(was changed to assert False by [Code Review: bugs] Music Assistant playback always returns True masking failuresΒ #418)test_ma_ignores_wrong_song_from_previous_requestβ race condition regression testtest_ma_matches_title_with_suffixβ MA appends "(Official HD Video)" etc.Test plan
connections=1on REVEAL broadcastπ€ Generated with Claude Code