Skip to content

Native streaming: unavailable-track guard pauses, but librespot keeps skipping through the whole queue #537

Description

@LargeModGames

Describe the bug
When librespot can't play any track on an account (the error audio key 0 1 block, librespot-org/librespot#1649), the stampede guard from #282 doesn't stop playback. It pauses after 3 consecutive Unavailable events, but librespot keeps loading the next track, so it still runs through the whole queue at machine speed. In a user's log it went to 17 failed tracks in 43 seconds with no input in spotatui, and CDN file loads started failing with rate limited. In a second session it went to 42 failures and Spirc state updates got 429 Too Many Requests. It only stopped when the queue ran out.

Cause
Spirc answers every PlayerEvent::Unavailable with handle_next (the Unavailable arm in connect/src/spirc.rs), and handle_unavailable also preloads the next track. A paused load_track still requests the audio key and the file, so the Pause the guard sends (UNAVAILABLE_ESCALATION_THRESHOLD in src/infra/player/events.rs) doesn't break the loop. DeferredPlayerCommand::Stop wouldn't either as written: it only calls player.stop() and leaves Spirc's state alone.

To Reproduce

  1. Log in with an account affected by Audio key error librespot-org/librespot#1649 (it mostly hits newer accounts).
  2. Start native playback of a playlist or album.
  3. Every track logs error audio key 0 1 then Skipping to next track, and the consecutive N count in native playback unavailable keeps climbing past 3.
[17:59:16][spotatui::infra::player::events][INFO] native playback unavailable (track spotify:track:1JbrVh45evNhbm3R75aYzg, consecutive 3)
[17:59:16][spotatui_librespot_playback::player][INFO] Loading <I Really Want to Stay at Your House> with Spotify URI <spotify:track:7mykoq6R3BArsSpNDjFQTm>
[17:59:16][spotatui_librespot_core::audio_key][ERROR] error audio key 0 1
...
[17:59:35][spotatui_librespot_playback::player][ERROR] Unable to load encrypted file: Error { kind: ResourceExhausted, error: "rate limited for at least another 0 seconds" }
...
[17:59:55][spotatui::infra::player::events][INFO] native playback unavailable (track spotify:track:1Qtoq02RTZ4alrR7vJ4Lai, consecutive 17)

Expected behavior
After 3 consecutive unavailable tracks, native playback stops and no more keys or files are requested until the user starts something again.

Screenshots
N/A, log excerpt above.

Desktop (please complete the following information):

  • OS: any
  • Terminal: any
  • Version: 0.42.0 (spotatui-librespot 0.8.3)

Additional context
The account-side key block is upstream and can't be fixed here. This issue is only about the guard. The fix probably belongs in the fork, either stopping Spirc's auto-advance after N consecutive unavailable tracks or exposing a Spirc stop the guard can call. The fork has issues disabled, so this one tracks it.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions