Plex Connect: fix queue cap of 50#3187
Conversation
There was a problem hiding this comment.
Pull request overview
This PR addresses Plex play queue truncation by requesting a larger item window when fetching an existing Plex PlayQueue, avoiding the default ~50 item cap that breaks longer queues.
Changes:
- Increase
PlayQueue.get(...)fetch window to 500 when loading a queue for playback. - Increase
PlayQueue.get(...)fetch window to 500 when refreshing/syncing an updated queue.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| # Use plexapi to fetch the play queue | ||
| def fetch_queue() -> PlayQueue: | ||
| return PlayQueue.get(self.provider._plex_server, playQueueID=queue_id) | ||
| return PlayQueue.get(self.provider._plex_server, playQueueID=queue_id, window=500) |
There was a problem hiding this comment.
Increasing the PlayQueue fetch window to 500 can significantly increase downstream work: _load_remaining_queue_tracks uses asyncio.gather over all remaining items, so this change can trigger hundreds of concurrent get_track calls. Consider adding a concurrency limit (e.g., semaphore/chunking) or otherwise throttling track resolution to avoid overloading Plex/MA and to reduce memory/latency spikes on large queues.
| return PlayQueue.get(self.provider._plex_server, playQueueID=queue_id, window=500) | |
| # Use a conservative window size to avoid excessive downstream concurrency | |
| return PlayQueue.get(self.provider._plex_server, playQueueID=queue_id, window=50) |
There was a problem hiding this comment.
I think this is a valid concern. Have you tested this with a big play queue to see what it does to latency?
There was a problem hiding this comment.
You're right. Let's keep it as a draft until I come up with a better solution but also for people to be aware of the reason of the bug.
|
Just need to address the copilot comments. |
For now a very permissive cap has been set. I think it should fix most issues. A more evolved fix should use the pagination and build the queue while parcouring the pages. Let me defer that to a later PR.