Repository navigation
fix(studio): previews framed from another site get no editing port; abandoned still jobs stop - #7793
Conversation
…diting port When the Studio server answers a preview document to another site's request, it now marks the document, and the runtime's editing agent ignores every connect in a marked document. The Studio's own frames, which load the preview from the same origin, keep the editing port. The marked copy carries no ETag, so it is never revalidated in place of the unmarked one.
Each still job now counts the requests waiting on it. A request whose connection closes leaves the job, and when the last one leaves, the job's ffmpeg is killed and the job is forgotten, so the next request starts afresh. A caller that passes no signal keeps the job running, and a request that has already closed starts nothing.
…l-ffmpeg still test
…ated A frame load of a preview from another site now drops If-None-Match and If-Modified-Since before the route answers, so it always gets a fresh, marked document instead of a 304 that could reuse the unmarked copy a browser cached for the Studio's own page on the same site. Subresource loads keep their validators.
jrusso1020
left a comment
There was a problem hiding this comment.
Reviewed at 2c18b57
The cross-site preview marker is checked on every editing-port connection. Frame/document validators are stripped before serving, so revalidation cannot reuse an unmarked response. Still requests detach independently, the last waiter aborts ffmpeg, and identity-based map cleanup prevents an old job from deleting its replacement.
Stack state: the current parent head 96959aa is an ancestor. This review covers the nine-file increment over that parent.
Validation: frozen install/full build passed; editing-agent 117 passed, preview/sandbox/origin/proxy suites 308 passed, including cancellation and shared-waiter coverage. Read the changed runtime/server files, queue/spawn consumers and token-preview route. No new native browser, Windows or hosted-site walkthrough performed.
Commands: bun run --cwd packages/core test src/runtime/editingAgent.test.ts --maxWorkers=1 and bun run --cwd packages/studio-server test src/helpers/proxyTranscoder.test.ts src/routes/preview.test.ts src/routes/preview.sandbox.test.ts src/createStudioApi.originGuard.test.ts --maxWorkers=1 (through the shared test gate).
Need: yes · Size: ok · Reuse: existing preview middleware, editing marker module and still scheduler · Simpler: attach waiter ownership to the existing shared job · Structure: fine (checked editing-port callers, token-route recursion and proxy/slot cleanup; no second scheduler)
Risk: medium — changes editing-channel admission and shared process cancellation.
Verdict: APPROVE
Reasoning: The marker/revalidation boundary and last-waiter cleanup are consistently wired and preserve the other callers' work.
— Rames
What
Why
Related work
Stacked on #7779, which adds the still slots and the cross-site guard these build on. #7778 already covers nested HLS playlists.
How
studio-server/createStudioApi.ts: for across-siteorsame-siteframe or document load of a preview HTML, the server stripsIf-None-MatchandIf-Modified-Since, injects a marker meta tag at the start of<head>, and drops the ETag. Chrome's HTTP cache is keyed by site, which ignores the port, so without the stripping a page on another local port could revalidate Studio's cached unmarked copy. Other cross-site requests, such as the Studio opaque frame's fonts, keep revalidating.core/runtime/editingAgent.ts: ignores connects in a marked document.studio-server/helpers/proxyTranscoder.tsandroutes/preview.ts: per-job waiter counts and an abort signal fromc.req.raw.signal.Test plan
Unit tests added/updated
Manual testing performed
Documentation updated (if applicable)
Comments follow CONTRIBUTING.md "Comments": they say why, not what, and a bug fix says what the code must do and how to reproduce the bug
core
editingAgent.test.ts117 pass. The studio-server preview, sandbox, origin-guard and opaque-frame tests andproxyTranscoder.test.tspass (277, 2 skipped). Each new test fails without its fix.Real Chrome:
query.A live still test with a slow fake ffmpeg: the process was killed when the client disconnected.
Not run on Windows (the kill test is skipped there, like the existing proxy kill test). hyperframes.studio was checked from the code, not live.