Skip to content

Fix infinite loop in plex_connect when handling refreshPlayQueue#3508

Closed
anatosun wants to merge 1 commit intomusic-assistant:devfrom
anatosun:refactor/plex-connect
Closed

Fix infinite loop in plex_connect when handling refreshPlayQueue#3508
anatosun wants to merge 1 commit intomusic-assistant:devfrom
anatosun:refactor/plex-connect

Conversation

@anatosun
Copy link
Copy Markdown
Contributor

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.

It should fix this issue.

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.
Copilot AI review requested due to automatic review settings March 30, 2026 13:21
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Prevents a circular queue-sync loop between Plex’s refreshPlayQueue callback and Music Assistant’s queue update events by applying the same _updating_from_plex guard used by other Plex command handlers.

Changes:

  • Set self._updating_from_plex = True at the start of handle_refresh_play_queue processing.
  • Ensure the guard is always cleared via a finally block.

@anatosun anatosun closed this Mar 30, 2026
@anatosun
Copy link
Copy Markdown
Contributor Author

Closing in favor of #3510

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Plex API (possibly due to metadata) is causing HA to error out

2 participants