Skip to content

Commit 18eb5be

Browse files
fix: skip server cleanup on session loss to keep playback alive
Symptoms observed in logs — the TCP session dies, then cleanup fails: ERROR librespot_core::session Connection to server closed. WARN librespot_connect::spirc unexpected shutdown ERROR librespot_core::session Broken pipe (os error 32) ERROR librespot_core::session Transport endpoint is not connected (os error 107) WARN librespot Spirc shut down unexpectedly When SpircTask exits because session.is_invalid(), the post-loop cleanup called handle_disconnect() (which sets play_status to Stopped and tries to notify Spotify), delete_connect_state_request(), and dealer().close(). All of these fail because the TCP connection is dead, and setting play_status to Stopped needlessly kills the Player. Now we detect session.is_invalid() and skip all server communication in the post-loop cleanup. The Player runs in a separate thread and continues playing from its audio buffer. main.rs will create a new session and Spirc. After fix — the "Broken pipe" and "Transport endpoint is not connected" errors no longer appear after session loss. The Player continues playing while the session reconnects (see next commit for state restoration evidence). Co-authored-by: Copilot <[email protected]>
1 parent 812c972 commit 18eb5be

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

connect/src/spirc.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -599,6 +599,14 @@ impl SpircTask {
599599
}
600600
}
601601

602+
if self.session.is_invalid() {
603+
// Session TCP connection died — skip server communication that
604+
// would fail anyway. The Player continues playing from its
605+
// buffer independently; main.rs will create a new session.
606+
warn!("session lost, skipping server cleanup");
607+
return;
608+
}
609+
602610
if !self.shutdown && self.connect_state.is_active() {
603611
warn!("unexpected shutdown");
604612
if let Err(why) = self.handle_disconnect().await {

0 commit comments

Comments
 (0)