Skip to content

Retry the remaining plex.tv calls that had no retry - #209

Merged
Brandon-Haney merged 2 commits into
StudioNirin:mainfrom
Brandon-Haney:pr/plextv-retry-consistency
Sep 3, 2026
Merged

Retry the remaining plex.tv calls that had no retry#209
Brandon-Haney merged 2 commits into
StudioNirin:mainfrom
Brandon-Haney:pr/plextv-retry-consistency

Conversation

@Brandon-Haney

Copy link
Copy Markdown
Collaborator

Two plex.tv entry points were still unretried while their siblings already had backoff.

The watchlist fetch

Constructing MyPlexAccount in the user is None branch of _fetch_user_watchlist was the last one without a retry. _get_main_account() and the switchHomeUser path both got one earlier. On an install with no home users that branch is the only watchlist fetch there is, so a single read timeout cost the whole run its array restore:

[USER:Brandon] Fetching watchlist media
ERROR (get Plex account for Brandon): plex.tv ... Read timed out
WARNING Skipping array restore - watchlist data incomplete

It now goes through _retry_plextv_call for the same 3 attempts with 2s/4s backoff as its siblings. Auth failures still fail on the first attempt, and exhausting the retries still guards array restore exactly as before.

The Settings user list

myPlexAccount() and users() both back /settings/plex/users and both are plex.tv round trips. A read timeout during the hourly refresh dropped the admin from the list until the next cycle, while the shared users loaded fine from the very next call:

Refreshing Plex data cache...
WARNING Could not get main account: plex.tv ... Read timed out
INFO Fetched 24 shared users

Capped at 2 attempts rather than PLEXTV_MAX_RETRIES, because this sits on a page request. Attempts here are paid in page latency, and giving up costs a stale user list rather than a skipped array restore.

How to test

  1. On a single-user install (no home users), run a cache operation while plex.tv is briefly unreachable. The run retries instead of logging Skipping array restore - watchlist data incomplete on the first timeout.
  2. Open Settings then Plex then Users during a plex.tv blip. The admin account stays in the list rather than disappearing until the next refresh.
  3. Confirm a genuine auth failure (bad token) still fails immediately rather than retrying.

Covered by tests/test_plex_api_main_account_retry.py and tests/test_settings_service_plextv_retry.py.

Constructing MyPlexAccount in the `user is None` branch of
_fetch_user_watchlist was the last plex.tv entry point without a retry;
_get_main_account() and the switchHomeUser path already had one.

On an install with no home users that branch is the only watchlist fetch
there is, so a single read timeout marked the watchlist incomplete and
skipped array restore for the whole run:

  [USER:Brandon] Fetching watchlist media
  ERROR (get Plex account for Brandon): plex.tv ... Read timed out
  WARNING Skipping array restore - watchlist data incomplete

Wrapping it in _retry_plextv_call gives the same 3 attempts with 2s/4s
backoff as its siblings. Auth failures still fail on the first attempt,
and exhausting the retries still guards array restore as before.
myPlexAccount() and users() back the Settings user list and both are
plex.tv round trips. A read timeout during the hourly refresh dropped the
admin from the list until the next cycle:

  Refreshing Plex data cache...
  WARNING Could not get main account: plex.tv ... Read timed out
  INFO Fetched 24 shared users

The shared users loaded from the very next call, so the two blocks keep
fetching independently rather than sharing one account.

Capped at 2 attempts instead of PLEXTV_MAX_RETRIES: this is reachable from
GET /settings/plex/users, so attempts are paid in page latency, and giving
up costs a stale user list rather than a skipped array restore.
@Brandon-Haney
Brandon-Haney merged commit 2a9c7a2 into StudioNirin:main Sep 3, 2026
2 checks passed
@Brandon-Haney
Brandon-Haney deleted the pr/plextv-retry-consistency branch September 3, 2026 18:47
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.

2 participants