From 1963c4c3d1d74c42423cea076282c9720a06c024 Mon Sep 17 00:00:00 2001 From: Anatosun Date: Mon, 30 Mar 2026 15:17:17 +0200 Subject: [PATCH] Fix infinite loop in plex_connect when handling refreshPlayQueue MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit handle_refresh_play_queue was missing the _updating_from_plex guard that all other command handlers use. Without it, any queue refresh from Plex would modify the MA queue, triggering _handle_queue_items_updated, which would recreate the Plex PlayQueue, causing another refreshPlayQueue — an infinite loop. The stale PlayQueue 404 errors were also a symptom of this. --- music_assistant/providers/plex_connect/player_remote.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/music_assistant/providers/plex_connect/player_remote.py b/music_assistant/providers/plex_connect/player_remote.py index a88a456372..0e32cd8ffe 100644 --- a/music_assistant/providers/plex_connect/player_remote.py +++ b/music_assistant/providers/plex_connect/player_remote.py @@ -857,6 +857,8 @@ async def handle_refresh_play_queue(self, request: web.Request) -> web.Response: This is called when the play queue is modified (items added, removed, reordered). We need to sync the entire updated queue state to MA while preserving playback. """ + # Set flag to prevent circular updates + self._updating_from_plex = True try: play_queue_id = request.query.get("playQueueID") @@ -955,6 +957,8 @@ def fetch_queue() -> PlayQueue: except Exception as e: LOGGER.exception(f"Error handling refreshPlayQueue: {e}") return web.Response(status=500, text=str(e)) + finally: + self._updating_from_plex = False async def handle_create_play_queue(self, request: web.Request) -> web.Response: """