[PR #198] [MERGED] Make the client/application more robust to network errors #660

Closed
opened 2026-03-02 23:49:16 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/aome510/spotify-player/pull/198
Author: @aome510
Created: 5/15/2023
Status: Merged
Merged: 5/16/2023
Merged by: @aome510

Base: masterHead: make_client_more_robust


📝 Commits (10+)

  • 25d04d1 create new streaming connection with a blocking task
  • f0e05fd store Spotify client's session in Arc
  • bd09d18 create a client function to connect to a Spotify device
  • 41d8167 refactor streaming connection codes
  • 034a813 handle initializing new streaming connections upon new session
  • d7aefa4 implement Client::new_session
  • ab3cf0f don't do logging for CLI commands
  • a085cec don't forget to send empty buffer to indicate end-of-chunk
  • f91c027 update authentication process to use AuthConfig
  • ed3905d avoid Rspotify not authenticated panic

📊 Changes

10 files changed (+274 additions, -240 deletions)

View changed files

📝 spotify_player/src/auth.rs (+72 -37)
📝 spotify_player/src/cli/client.rs (+17 -8)
📝 spotify_player/src/client/handlers.rs (+18 -32)
📝 spotify_player/src/client/mod.rs (+107 -69)
📝 spotify_player/src/client/spotify.rs (+22 -19)
📝 spotify_player/src/config/mod.rs (+2 -9)
📝 spotify_player/src/main.rs (+27 -45)
📝 spotify_player/src/state/mod.rs (+0 -5)
📝 spotify_player/src/streaming.rs (+8 -16)
📝 spotify_player/src/token.rs (+1 -0)

📄 Description

Resolves #150

Summary

This PR adds new changes that make spotify_player more robust to network errors, which allows the application to re-initialize a new Spotify session and reconnect to a new streaming connection after the network errors are resolved.

Changes

  • make the client/application more robust to network errors by
    • re-authenticating and initializing a new session if invalid before handling any client requests
    • creating/connecting to a new streaming connection upon a session re-authentication
    • avoiding panics in third-party codes
  • update how the application creates a new streaming connection
  • update client socket's result/error sending logic
  • update the authentication codes to allow code reuse and better error messages
  • disable logging when handling CLI commands

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/aome510/spotify-player/pull/198 **Author:** [@aome510](https://github.com/aome510) **Created:** 5/15/2023 **Status:** ✅ Merged **Merged:** 5/16/2023 **Merged by:** [@aome510](https://github.com/aome510) **Base:** `master` ← **Head:** `make_client_more_robust` --- ### 📝 Commits (10+) - [`25d04d1`](https://github.com/aome510/spotify-player/commit/25d04d1389bcca93d1a584aed41112bef395c463) create new streaming connection with a blocking task - [`f0e05fd`](https://github.com/aome510/spotify-player/commit/f0e05fd66feca5568a8f689becdf744ac816eb87) store Spotify client's session in Arc<Mutex> - [`bd09d18`](https://github.com/aome510/spotify-player/commit/bd09d189e219f95bd1086f1fb6772db927594211) create a client function to connect to a Spotify device - [`41d8167`](https://github.com/aome510/spotify-player/commit/41d81676b746883c8345cedf44dfd317b5fe5ded) refactor streaming connection codes - [`034a813`](https://github.com/aome510/spotify-player/commit/034a813dfaa34fa0141fea42a274f3c3ab2213a9) handle initializing new streaming connections upon new session - [`d7aefa4`](https://github.com/aome510/spotify-player/commit/d7aefa41320b93bd6cd4ef8166d21de28712ff57) implement `Client::new_session` - [`ab3cf0f`](https://github.com/aome510/spotify-player/commit/ab3cf0f196505b45d8a7acc7e94d5963d2de14cb) don't do logging for CLI commands - [`a085cec`](https://github.com/aome510/spotify-player/commit/a085cec03a2c200fb05fa28bb6f4372a54dcae8c) don't forget to send empty buffer to indicate end-of-chunk - [`f91c027`](https://github.com/aome510/spotify-player/commit/f91c027c351b0cc3961ebdf961a2669b85bedb09) update authentication process to use `AuthConfig` - [`ed3905d`](https://github.com/aome510/spotify-player/commit/ed3905d4588c96d056ab42830c9bef25f9caac06) avoid `Rspotify not authenticated` panic ### 📊 Changes **10 files changed** (+274 additions, -240 deletions) <details> <summary>View changed files</summary> 📝 `spotify_player/src/auth.rs` (+72 -37) 📝 `spotify_player/src/cli/client.rs` (+17 -8) 📝 `spotify_player/src/client/handlers.rs` (+18 -32) 📝 `spotify_player/src/client/mod.rs` (+107 -69) 📝 `spotify_player/src/client/spotify.rs` (+22 -19) 📝 `spotify_player/src/config/mod.rs` (+2 -9) 📝 `spotify_player/src/main.rs` (+27 -45) 📝 `spotify_player/src/state/mod.rs` (+0 -5) 📝 `spotify_player/src/streaming.rs` (+8 -16) 📝 `spotify_player/src/token.rs` (+1 -0) </details> ### 📄 Description Resolves #150 ## Summary This PR adds new changes that make `spotify_player` more robust to network errors, which allows the application to re-initialize a new Spotify session and reconnect to a new streaming connection after the network errors are resolved. ## Changes - make the client/application more robust to network errors by - re-authenticating and initializing a new session if invalid before handling any client requests - creating/connecting to a new streaming connection upon a session re-authentication - avoiding panics in third-party codes - update how the application creates a new streaming connection - update client socket's result/error sending logic - update the authentication codes to allow code reuse and better error messages - disable logging when handling CLI commands --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-02 23:49:16 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/spotify-player#660
No description provided.