Skip to content

fix(qobuz): retry a stalled segment sooner - #730

Merged
LargeModGames merged 1 commit into
mainfrom
fix/qobuz-segment-stall
Oct 8, 2026
Merged

LargeModGames merged 1 commit into
mainfrom
fix/qobuz-segment-stall

Conversation

@LargeModGames

@LargeModGames LargeModGames commented Oct 8, 2026 •

Copy link
Copy Markdown
Owner

Summary

During a short Qobuz-side outage, every segment request got no answer. Each attempt waited the full 30 s request timeout, so a track showed "loading" for about 90 s. Then it failed with decoding audio stream: The format of the data has not been recognized., which hid the real cause. The segment errors were not in the log either, because stream-download logs through tracing and the app log only records log.

  • The Qobuz client gets a 10 s read timeout. A stalled request now fails after 10 s without data, and the retry opens a new connection. A slow download that still receives data is not affected.
  • Each failed segment attempt is logged as [qobuz] segment N attempt i/3: <error>.
  • SegmentStream keeps its final error in a shared OnceLock. prepare_track and download_for_queue report that error in place of the decoder or copy error.

Testing

  • cargo fmt --all -- --check (exit 0)
  • cargo clippy --features all-sources -- -D warnings, cargo clippy --no-default-features --features telemetry,tui -- -D warnings and cargo clippy --no-default-features --features telemetry -- -D warnings: all clean
  • cargo test --features all-sources qobuz: test result: ok. 70 passed; 0 failed; 1 ignored
  • cargo test --no-default-features --features telemetry,tui: test result: ok. 1461 passed; 0 failed
  • New a_stalled_segment_is_retried_after_the_read_timeout: the fake server does not answer the first request for segment 1. With only the old request timeout, the test took 30.0170331s. With the read timeout, it passes in 0.32 s with the full track.
  • New a_failed_reader_keeps_the_segment_error_for_the_caller and a_segment_failure_replaces_the_decoder_error.
  • Live: I played Qobuz tracks in a full build (all-sources,cover-art,mcp-server,ai-dj) on Windows, and the log has no Qobuz warnings.

Additional notes

I could not make the real outage happen again, so the stall recovery is tested against the fake server only. If Qobuz refuses or stalls every request, the track still fails, but after about 30 s with the real error and not after 90 s with a decoder error.


💬 Questions or want to chat with other contributors? Join the spotatui Discord.

Summary by CodeRabbit

  • Bug Fixes
    • Qobuz downloads now report the underlying segment failure when a stream or track cannot be read or prepared, making playback and download errors more informative.
    • Stream requests now have a 10-second read timeout, helping prevent stalled responses from hanging indefinitely.
    • After repeated segment-fetch failures, the stream stops and preserves the failure cause for subsequent operations.

A segment request that got no answer waited the full 30 s request
timeout on each of its three attempts, so a track showed "loading" for
about 90 s and then failed with a decoder error that hid the cause.

- Add a 10 s read timeout to the Qobuz client, so a stalled request
  fails sooner and the retry opens a new connection.
- Log each failed segment attempt. stream-download logs through
  tracing, which the app log does not record.
- Keep the final segment error and report it in place of the decoder
  or copy error.
@coderabbitai

coderabbitai Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: LargeModGames/spotatui/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 752a2faa-47c0-4be7-ba03-f35d0be74e50
📥 Commits

Reviewing files that changed from the base of the PR and between 9265a6d and ee20753.

📒 Files selected for processing (4)
  • src/infra/qobuz/dispatch.rs
  • src/infra/qobuz/mod.rs
  • src/infra/qobuz/stream/download.rs
  • src/infra/qobuz/stream/progressive.rs

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.


📝 Walkthrough

Walkthrough

Qobuz stream requests now use a 10-second read timeout. Progressive streams share and expose terminal segment-fetch errors. Download and decoder-preparation error handling use a recorded segment error when one is available.

Changes

Qobuz stream error handling

Layer / File(s) Summary
Read timeout and progressive failure state
src/infra/qobuz/mod.rs, src/infra/qobuz/stream/progressive.rs, src/infra/qobuz/stream/download.rs
The shared Qobuz client adds a 10-second read timeout. SegmentStream stores terminal fetch errors in shared state and exposes that state through failure(). Tests cover a stalled segment, a missing segment, and failure-cause retrieval.
Download and preparation error causes
src/infra/qobuz/dispatch.rs
Download-read and decoder-preparation errors use the recorded segment failure when available. Otherwise, the original error is retained.

Priority: ⬇️ Low

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to ee207

The change is mergeable after normal checks; no actionable issue is established.

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title uses the permitted conventional-commit prefix fix(qobuz):, clearly describes the stalled-segment retry change, and uses a concise imperative subject.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
✨ Simplify code
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Oct 8, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.30769% with 7 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/infra/qobuz/dispatch.rs 73.9% 6 Missing ⚠️
src/infra/qobuz/stream/download.rs 90.9% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@LargeModGames
LargeModGames merged commit dd7a200 into main Oct 8, 2026
35 checks passed
@LargeModGames
LargeModGames deleted the fix/qobuz-segment-stall branch October 8, 2026 18:28
LargeModGames added a commit that referenced this pull request Oct 11, 2026
# Summary

Version bump and changelog for v0.44.0. No application code changes.

- `Cargo.toml` and `Cargo.lock` go to 0.44.0, and `SECURITY.md` names
0.44 as the supported version.
- `CHANGELOG.md`: `## [Unreleased]` is now `## [v0.44.0] 2026-10-12`. I
checked every PR merged since v0.43.0 against it and added 24 entries
that were missing, for #524, #569, #570, #574, #593, #618, #623, #624,
#651, #652, #656, #675, #684, #700, #701, #706, #707, #709, #718, #719,
#722, #730, #741 and #742.
- Five older entries blamed the Web API, Development Mode or the token
refresh, which #752 removed. They now describe what a v0.44 user sees.
The #752 entry also says that related artists are empty for now.
- The agent plugin goes to 0.2.0 (both manifests and the marketplace
entry), because its skill now lists the ten new MCP tools.
- README and `docs/roadmap.md`: rspotify is only models and ids now,
`--debug` logs every Spotify request, recommendations work again, and
related artists come back empty.
- The `spotatui.wiki` submodule moves to the commit that replaces the
client-id setup with the pairing login.

# Testing

- `cargo update -p spotatui --offline`, then `cargo metadata --locked`:
ok
- `cargo check --locked`: ok (`Checking spotatui v0.44.0`)

# Additional notes

This is the first release without a client id. Every Spotify user logs
in once more with the pairing code, and Spotify in spotatui needs
Premium.

---
<sub>💬 Questions or want to chat with other contributors? Join the
[spotatui Discord](https://spotatui.com/discord).</sub>


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **New Features**
* Search and sort playlists using loaded tracks, play playlists
randomly, and browse artist albums across pages.
* Spotify sessions now support HTTP proxies; listening parties stay
connected with keep-alives.
* **Improvements**
* Playback handoffs, polling, and slow Spotify operations have been
adjusted for smoother playback.
* Skipped downloads can be canceled, and AI DJ/MCP playback can continue
when off-screen.
* **Bug Fixes**
* Fixed issues with theme color startup, key handling, focus navigation,
cursor placement, playlist sorting, and Qobuz retries.
* **Documentation**
  * Updated installation, keybinding, and Spotify guidance.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant