Thumbnail connections leave with their document

Saves must not queue behind media from a document the person already left.

2026-10-02 · source 0337620 · audited 4 · trusting 0 · not exercised 1 · decisions 0

In one breath

The scheduler bounds work in one document, but old documents retain thumbnail connections after navigation; the lifecycle actor must abort that work on pagehide and resume retained leases on pageshow.

Where the value travels

pagehide / pageshow → One lifecycle actor → Thumbnail scheduler → AbortSignal → fetch / media decoder

The verified boundaries

Scheduler owns work

entry.controller = new AbortController();
entry.request.load(controller.signal)
Producer packages/studio/src/player/lib/thumbnailScheduler.ts:291-301; consumer packages/studio/src/player/components/CompositionThumbnail.tsx:104-112.

The controller exists, is passed to the actual fetch, and is already aborted when the final lease leaves. Document navigation currently has no scheduler actor.

Abort and retain

entry.preempted = true;
entry.controller?.abort();
Producer thumbnailScheduler.ts:228-231; consumer catch/requeue/pump at :301-320 and :344-351. Paths relative to packages/studio/src/player/lib.

Existing preview reload preempts composition jobs and retains leases. Pagehide and document visibility suspension must be a separate cause: pageshow cannot release a preview-reload hold. While suspended, no queued thumbnail kind may start.

The receiving HTTP route

await thumbnailGenerationCoordinator.acquire(
  cachePath, c.req.raw.signal, async (signal) => adapter.generateThumbnail({ signal, ... })
)
packages/studio-server/src/routes/thumbnail.ts:227-244; client fetch signal at CompositionThumbnail.tsx:108-110.

Client abort releases its browser connection. Server cancellation propagation is a separate host concern; the dev HTTP bridge must forward response disconnects into that signal so queued renders lose their leases. The endpoint is a one-shot image response, not a stream or long poll. Its serial queue had no server deadline; the existing client deadline is 30 seconds, but old-document timers may stop after navigation. Lifecycle abort plus propagated disconnect removes abandoned work instead of waiting for that timer.

How it says no

SignalMeaning
AbortErrorRequested cancellation; retained leases return to the queue. No thumbnail error state.
Document hiddenAbort active work and hold all queued thumbnail kinds.
Preview reload remains activePageshow permits other thumbnail kinds, but composition work retains its existing hold.

Decision already supplied

Saves never queue behind media. Fix the held connections, preserve a tight persistence bound. No new product decision.

Coverage, honestly

Audited: scheduler, real composition fetch, preview-reload caller, server consumer. Runtime: Chrome NetLog shows all six sockets occupied by thumbnails, four from previous documents and two current, at a PUT stalled by the per-host socket limit. A real HTTP regression holds render responses open across hidden project documents and verifies a durable drop within 15 seconds. Removing the lifecycle binding fails that exact persistence assertion. Unit checks cover all thumbnail kinds, resumption, independent preview holds and actual HTTP disconnects.

What would prove this page wrong

Hold real thumbnail render responses open, leave two project documents, then drop a clip. Old-document render requests must cancel before the next document saves; the drop must persist within 15 seconds while current thumbnails remain unfinished. Cache-only poster reads return an image or 404 without entering the render queue. Retained leases must resume and preview-reload holds must survive pageshow.