Skip to content

Commit

Permalink
fix: Don't panic when token update fails
Browse files Browse the repository at this point in the history
* fix a panic when token update fails

sometimes we get an `Err` from `token_rx.recv()`, shouldn't panic in such cases

* chore(docs): Update Changelog

---------

Co-authored-by: Henrik Friedrichsen <henrik@affekt.org>
  • Loading branch information
eprst and hrkfdn authored Mar 2, 2024
1 parent b70df76 commit 9a26c58
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Crash due to misconfigured or unavailable audio backend
- Missing MPRIS signal for volume changes when volume is changed from inside `ncspot`
- Crash when `ncspot` tried to update an API token that was still valid
- Panic when token update attempt fails
- Complete freeze when `ncspot` was running for a long time

## [1.0.0] - 2023-12-16
Expand Down
2 changes: 1 addition & 1 deletion src/spotify_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ impl WebApi {
let api_token = self.api.token.clone();
let api_token_expiration = self.token_expiration.clone();
Some(ASYNC_RUNTIME.get().unwrap().spawn_blocking(move || {
if let Some(token) = token_rx.recv().unwrap() {
if let Ok(Some(token)) = token_rx.recv() {
*api_token.lock().unwrap() = Some(Token {
access_token: token.access_token,
expires_in: chrono::Duration::seconds(token.expires_in.into()),
Expand Down

0 comments on commit 9a26c58

Please sign in to comment.