fix(plex): a server that restarts mid-episode is waited out, not reported as a stream that cannot play

During a deploy the gateway answers 502 (or nothing answers at all) until the app is back. The
player took the first such answer for a broken stream: it said "Playback couldn't start" over a
picture still playing from its buffer, stopped loading, and never asked again, so the episode froze
where the buffer ended with the error still up. Now a 502/503/504 or no answer is the server being
away: the buffer keeps playing undisturbed, the session is asked for again where the viewer is
(2, 4, 8, then every 15 s), and the error is said only after three minutes away. A seek or another
item replaces a pending retry. Measured on localdev: a 45 s API stop now resumes at the viewer's
position, where it froze with the error before.
This commit is contained in:
2026-10-23 14:42:17 +02:00
parent cd5b26efa7
commit 38c71b7b4f
3 changed files with 190 additions and 12 deletions
+7 -1
View File
@@ -232,7 +232,13 @@ export default function PlexPlayer({ itemId, onClose, queue, fromStart = false }
position: () => absRef.current,
duration: () => durationRef.current,
now: () => Date.now(),
statusOf: (e) => (e instanceof HttpError ? e.status : undefined),
later: (fn, ms) => {
const timer = window.setTimeout(fn, ms);
return () => window.clearTimeout(timer);
},
// `req` rethrows fetch's own TypeError when nothing answered at all: that is a status of 0.
statusOf: (e) =>
e instanceof HttpError ? e.status : e instanceof TypeError ? 0 : undefined,
onLoadStart: () => setBuffering(false),
onFragLoaded: (frag) => fragMeterRef.current.add(frag),
// Fatal ones are what the viewer saw fail; the recoverable ones hls.js retries by itself only