fix(spotify_connect): ignore trailing sink event to prevent playback thrashing (...
authorAndrew Pryde <andrew@rocketpod.co.uk>
Thu, 22 Jan 2026 11:37:21 +0000 (11:37 +0000)
committerGitHub <noreply@github.com>
Thu, 22 Jan 2026 11:37:21 +0000 (12:37 +0100)
* 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 <marvinschenkel@gmail.com>
music_assistant/providers/spotify_connect/__init__.py

index 90044187ae36c1c296158db6fd093e7b9304a914..5b9c90059d1ca9b4dd5d7a3aae33c37ee9857edc 100644 (file)
@@ -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: