Repository navigation
fix(studio-server): preview leaves out linked outside files a render leaves out - #9030
Conversation
…llow a render's rule
…leaves out A project file that links outside the project is served, and decoded for the timeline's sound, only when a render of the project would bring it in: the type and private-location rule moves from the producer to studio-server, and the host can refuse every outside file for a project. The CLI preview asks the same question its renders ask.
Edit accuracy: accurate 275 (base branch 273), smooth 57 of thoseThe gate passes. Newly passing (2)
Not banked yet, reported and not gated (bank a full-grid run's baseline.json) (2)
Quarantined, measured but not gated (0) |
jerry-heygen
left a comment
There was a problem hiding this comment.
Keep the outside-file checks off the Studio request loop. packages/studio-server/src/helpers/outsideFile.ts:220–227 calls synchronous real-path resolution before the first await, even for an ordinary in-project file or a missing file. A slow project drive can now block unrelated Studio requests. Exact-head CI run 46151467310 confirms the regression: both preview.offLoop.test.ts cases record realpathSync.native on the request loop, and the cached-waveform stall test records a blocked tick.
For eligible linked media, packages/cli/src/server/studioServer.ts:603 also runs the synchronous received-record walk on each asset request, including each byte-range refill. Keep the same refusal policy, but use the existing off-loop filesystem pattern for both the path/type checks and the CLI policy lookup. Keep the stalled-drive regressions and the new refusal tests passing. The CLI and Studio shards and producer unit/integration jobs passed; I did not run a live preview.
— Jerrai (pr-review)
A file with no link on its path inside the project needs no outside-file work. A linked one has its real paths, type and folder read with the async calls the other preview checks use, deciding with the same rule a render uses. The CLI asks a project's received-film answer once per change, not per request.
jerry-heygen
left a comment
There was a problem hiding this comment.
Changes requested at b8e7e5b9. The async path checks fix the ordinary-file and missing-file paths, but the CLI still blocks the request loop on the first eligible linked-asset request after startup or a project change. packages/cli/src/server/studioServer.ts:588–592 fills the empty cache by calling synchronous outsideAssetsAllowed, which calls receivedRecordStatus and walks the project with readdirSync. The cache avoids repeat scans only until the watcher clears it. The new held-drive test uses the Studio route adapter, not this CLI hook, so it doesn't cover a cold cache or a refresh.
Keep the render refusal policy, but compute the CLI decision off the request loop even on a cache miss or invalidation. Add a regression that exercises the real CLI hook with an eligible linked asset and an empty or invalidated cache.
— Jerrai (pr-review)
…erves The cached answer is kept only while the received-files records at and above the project, and the host's state file, are unchanged; a record written by an import into a folder above the project, which the project's watcher does not see, now ends the cached answer too.
…side-file rule Export's rule for linked files outside a project now lives in studio-server, which the preview and the producer both call, so the packed size is 203,563 bytes as measured by the publish check.
jerry-heygen
left a comment
There was a problem hiding this comment.
Changes requested at 8ce5f878. The package-size budget update does not change the remaining request-loop issue. On a cold cache or after the received-record stamp changes, packages/cli/src/server/studioServer.ts:603–610 still calls the synchronous outsideAssetsAllowed path, which walks the project with readdirSync. The async stamp check does not move that walk off the request loop. On a slow drive, one eligible linked-asset request can still stall unrelated Studio requests.
Please move the cold policy lookup off the request loop without changing the refusal policy, and cover it through the real CLI adapter with an empty or invalidated cache. The exact-head hosted support, CLI, and producer tests ran and passed; that does not demonstrate nonblocking behavior on this path.
— Jerrai (pr-review)
…t loop The received-files lookup is written once as a generator of disk reads: a render runs it with sync reads as before, and Studio's preview awaits it with async reads, sharing one lookup per project while a miss is in flight.
jerry-heygen
left a comment
There was a problem hiding this comment.
Changes requested at 0f095306. The CLI now awaits the filesystem walk, and the new tests exercise the real route on a cold and invalidated cache. That fixes the synchronous directory-read blocker.
The lookup now rereads the entire host-state file for each folder without its own record when HYPERFRAMES_RECEIVED_STATE_FILE is set. fsSteps.ts:107–124 reads the body before privateProjectFile.ts:131–141 checks the stamp, so a cache hit saves parsing but not I/O. The old path read the body only when the stamp changed. On a slow drive this serial work can exhaust the walk budget and turn an otherwise allowed linked asset into a 404; the sync render path also picks up the extra reads. Please preserve the stamp-based read avoidance, or reuse a single host-state snapshot per lookup, and test a multi-folder project with host state configured.
The exact-head Fallow audit also failed. The hold is for the lookup regression above, not the audit score.
— Jerrai (pr-review)
jerry-heygen
left a comment
There was a problem hiding this comment.
Approved at 73b26ff0. The real Studio route now awaits the received-record filesystem lookup on cold and invalidated caches, and the latest commit updates the Windows tests to exercise the new interfaces. The original request-loop blocker is fixed.
Follow-up: the walk can still reread an unchanged host-state file for multiple folders when host state is configured. Reuse the cached read and cover a multi-folder lookup; I did not find evidence that this refuses an ordinary project on an ordinary drive. Hosted CI was still running when checked, and I did not run a live preview.
— Jerrai (pr-review)
What
A project file that links to a file outside the project now loads in preview only when a render of that project would bring it in. Previously preview served any linked file, so it could show files a render leaves out.
Why
Preview should show what export renders. Export already leaves out a linked file outside the project when it sits in a hidden or app-data folder, when its type is not media, font, image, CSS or script, and, for a film someone else sent, every such file. Preview skipped all three, so a linked file could load in preview and still be missing from the render.
How
@hyperframes/studio-server(outsideLinkRefusalinhelpers/outsideFile.ts), and the producer calls it, so render and preview share one rule.servesProjectPath, asks that rule for every file whose real path leaves the project. The preview file route and the timeline's sound routes (pcm,peaks,waveform), which all followed links before, now go through it and answer their usualnot found.outsideAssetsAllowed(projectDir), lets the host turn off every linked outside file for a project. The CLI preview answers it withoutsideAssetsAllowed, the same check its renders use.Test plan
preview.outsideLinks.test.ts: a linked.binoutside the project, a linked picture in an app-data folder, and any linked file when the host refuses outside files, are not served, and a linked sound in an app-data folder is not decoded for the timeline. A linked picture from a shared folder is served when the host allows it.preview.outsideLinks.test.ts> "does not serve a linked file a render would leave out for its type", "does not serve a linked picture in an app's data folder", "does not serve any linked file when the host refuses outside files for the project" and "does not decode a linked sound in an app's data folder for the timeline" fail on a commit with only the tests. Taking the render rule out of the helper fails the first, second and fourth; ignoring the host's answer fails the third.preview.test.ts(including the shared-folder case from Preview server does not serve image assets referenced through external symlinks #2760),outsideFile.test.ts,peaks.test.ts,pcm.test.tsandwaveform.test.ts, 202/202. Producerpaths,animatedGifPrepandfileServertests 135/135. CLIstudioServer.previewAssets,studioServer.receivedRecord,studioServer.registryInstallandreceivedRendertests 133 passed, 5 skipped. Typecheck clean in studio-server, producer and cli.No visible change
Preview of your own projects is unchanged, unless a linked file is one a render already leaves out.