From a50455019611867e287e30562b3bfd07292b674a Mon Sep 17 00:00:00 2001 From: npeter83 Date: Thu, 8 Oct 2026 01:16:30 +0200 Subject: [PATCH] docs: the superseded fallback answers its own session; who uses beacon() --- backend/app/plex/stream.py | 5 +++-- frontend/src/lib/api/core.ts | 11 ++++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/backend/app/plex/stream.py b/backend/app/plex/stream.py index 393bea58..043539e7 100644 --- a/backend/app/plex/stream.py +++ b/backend/app/plex/stream.py @@ -744,8 +744,9 @@ def start_session( # `replace_only` makes the supersede identity-aware for the runtime fallback: the whole # check-and-replace happens under ONE _lock, so a newer same-key session (a concurrent # seek-restart) installed between the fallback's decision and here is never clobbered. When the - # registered session is no longer `replace_only`, we abort and return None (the caller yields to - # whoever is registered now). The INITIAL spawn never gets None — see its call site. + # registered session is no longer `replace_only`, we abort and return None, and the caller + # answers with its own dead session — never the newer one, whose id a stale requester would + # stop. The INITIAL spawn never gets None — see its call site. # Software-fallback encode tuning — read only on the SW transcode path (the VAAPI path and # remux ignore preset/crf/max_height, and remux must not touch the DB for them). preset, crf, max_height = "veryfast", 20, 0 diff --git a/frontend/src/lib/api/core.ts b/frontend/src/lib/api/core.ts index 1f7dbb9e..d7f0abfe 100644 --- a/frontend/src/lib/api/core.ts +++ b/frontend/src/lib/api/core.ts @@ -285,11 +285,12 @@ export function identityHeaders(): Record { }; } -// Fire-and-forget POST that survives page unload (keepalive) — shared by the resume-position -// beacons (YT + Plex players). A normal fetch is cancelled on unload and React effect cleanup -// doesn't run on a full reload, so without keepalive the last position (esp. right after a seek) -// would be lost. `onSettled`: the request has been answered (or failed) — for a caller whose cached -// view must be read again once the write is on the server. +// Fire-and-forget POST that survives page unload (keepalive) — for every write a closing page must +// still make: the resume checkpoints of the YouTube, Plex and library players, the Plex session stop, +// the diagnostics flush. A normal fetch is cancelled on unload and React effect cleanup doesn't run +// on a full reload, so without keepalive the last position (esp. right after a seek) would be lost. +// `onSettled`: the request has been answered (or failed) — for a caller whose cached view must be +// read again once the write is on the server. export function beacon(url: string, body: Record, onSettled?: () => void): void { try { void send(url, {