From d4d9e931cd3242d6614965370d64dc2d9b9dbac5 Mon Sep 17 00:00:00 2001 From: Andrew Pryde Date: Thu, 22 Jan 2026 11:37:21 +0000 Subject: [PATCH] fix(spotify_connect): ignore trailing sink event to prevent playback thrashing (#2976) * fix(spotify_connect): ignore trailing sink event to prevent playback thrashing The librespot daemon emits a trailing 'sink' event after disconnect. MA was misinterpreting this as a new playback request, causing the disconnecting player to immediately re-activate and steal the session back. This adds a check to ignore 'sink' events if the session is not connected. * Fix backport pipeline --------- Co-authored-by: Marvin Schenkel --- music_assistant/providers/spotify_connect/__init__.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/music_assistant/providers/spotify_connect/__init__.py b/music_assistant/providers/spotify_connect/__init__.py index 90044187..5b9c9005 100644 --- a/music_assistant/providers/spotify_connect/__init__.py +++ b/music_assistant/providers/spotify_connect/__init__.py @@ -755,6 +755,13 @@ class SpotifyConnectProvider(PluginProvider): # this player has become the active spotify connect player # we need to start the playback if event_name in ("sink", "playing") and (not self._source_details.in_use_by): + # If we receive a 'sink' event but we are not officially connected + # (i.e. we just disconnected), ignore it to prevent accidental + # re-activation of this player (trailing event from dying session). + if event_name == "sink" and not self._connected_spotify_username: + self.logger.debug("Ignoring trailing sink event while disconnected") + return Response() + # Check for matching Spotify provider now that playback is starting # This ensures the Spotify music provider has had time to initialize if not self._connected_spotify_username or not self._spotify_provider: -- 2.34.1