Repository navigation
fix(cli): cloud render sends one zip when it fits and uploads only the largest media - #7859
Conversation
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Automations to automatically generate PRs for you. |
jrusso1020
left a comment
There was a problem hiding this comment.
Request changes at 41ce7e87. Uploading largest-first until the zip fits is the right idea, and the concurrency helper's settle-before-reject change is sound. But one part of the change drops media that a render needs.
Blocking: small media named by a script-built path is now left out of the zip, even when everything fits.
dropUnusedMedia now removes any unreferenced media file, where the old dropUnusedHeavyFiles only removed files of 5 MB or more. It runs before the budget loop and doesn't depend on the budget. "Unused" is decided by static references (referencedFiles) plus isStillMentioned. isStillMentioned only matches a whole file stem between quotes or slashes, so a path a script assembles at run time doesn't count as a mention. Image sequences are the obvious case: "frames/frame_" + i + ".png".
Probe (vitest, real buildPublishFileMap plus offloadHeavyMedia, no upload): index.html has a script that loads frames/frame_${i}.png for i = 1–3, and the three PNGs are a few bytes each.
- At this head (with a 190 MB budget, or none): the file map afterwards is
["index.html"]. All three frames are gone from the zip, so the cloud render can't load them. - With main's
offload.ts/concurrency.ts: the file map keepsframes/frame_1.png … frame_3.png.
That conflicts with the description ("When the files the film uses fit under the 200 MB upload limit, they go as one zip"). A project that fit and rendered before can now render with missing frames. Possible fixes:
- Keep the old 5 MB floor for dropping unreferenced media.
- Drop unreferenced media only while the zip is over budget, largest first, the same way as uploads.
- Never drop media that a script could be loading, e.g. when its folder or stem prefix appears in script code.
Whichever you pick, please add a test with a script-built path that stays in the zip when it fits.
CI
Commentsfails: the comment share rose incloud/offload.ts(57 → 66 lines) andcommands/cloud/render.ts(96 → 97).Fallow auditfails. Its log wasn't available yet while the run was in progress.
Non-blocking
left -= item.size_bytes: ifsize_bytesis the uploaded size after a trim or re-encode, it's smaller than the staged bytes that left the zip, soleftstays high. That can upload a file or two more than needed. It's conservative, so it isn't wrong, but subtracting the staged size would be exact.- Now that the budget loop exists, the no-budget path ("every used media file goes up") has no production caller. Only
cloud rendercallsoffloadHeavyMedia, and it always passes a budget. You could make the budget required.
Need: real (projects of many mid-size files were refused) · Size: ok · Reuse: runWithConcurrencyLimit, extended with a safer failure mode · Simpler: fine · Structure: fine
Risk: medium as posted. Renders silently lose media a script loads. Low once unused-media dropping is scoped back.
— Rames
Edit accuracy: accurate 267 (base branch 267), smooth 109 of thoseThe gate passes. Quarantined, measured but not gated (8)
Unstable (1)
|
|
Thanks, the frame-sequence case was real. Fixed at Blocking: unused media dropped when the zip fits. I took your second option. Unused media now leaves the zip only while the zip is over budget, largest first, before any upload (
CI.
Non-blocking.
Tests at this head, Linux, |
jrusso1020
left a comment
There was a problem hiding this comment.
Re-review at c4e7e1a2. My earlier blocker is fixed, but one new test in this PR is flaky, so I'm requesting changes for that one item.
Need ✅ · Size ✅ · Reuse ✅ · Simpler ✅ · Structure ✅ · Risk: low (one test to make deterministic)
Resolved: unused media left the zip regardless of the budget. dropUnusedMediaWhileOver now drops unused media largest first, and only while the zip is over zipBudgetBytes. With no budget it is 0, so all unused media still goes, as before. uploadLargestWhileOver starts from the size that's left after that. Two new tests cover it: "keeps frames a script loads by a built path when the zip fits", which is my earlier probe, and "uploads nothing and keeps every file when the zip fits". Both are red against the old dropUnusedMedia, because nothing in the page's text names frame_1.png, so the frames counted as unused and were dropped whatever the budget. Subtracting stagedSize(batch[index]) rather than item.size_bytes is also right: the staged size is what actually leaves the zip. Comments and Fallow audit are green at this head.
Blocking: offload.test.ts › "uploads up to eight files at once" is flaky. The Flake gate failed it in 2 of 10 runs at this head, both times with expected 7 to be 8 (run 43754689971). Each worker does async work (hashing and the cache lookup) before it calls upload, and the fake upload resolves after a fixed 20 ms. So the first upload can finish before the eighth worker reaches upload, and the peak is 7. On main this would fail about one CLI unit run in five. Suggested fix: hold the fake uploads until 8 are in flight, then release them, instead of using a timer. For example, park each call on a promise, and when inFlight reaches 8 (or every remaining file has started), resolve the parked calls. Then peak === 8 is exact, and a regression to fewer than 8 at once fails the run every time instead of 20% of the time.
— Rames
|
Fixed at On a Linux box: the test passes 30 runs in a row. With |
jrusso1020
left a comment
There was a problem hiding this comment.
Re-review at 1ccbb7a (test-only change since c4e7e1a).
The flake is gone, because parking uploads until eight are in flight makes reaching 8 deterministic. But the test no longer checks the upper bound its name promises ("uploads up to eight files at once"). The parked uploads are released in the same tick the eighth one starts, so they finish before a ninth worker gets past its own hashing and cache read and calls upload. Results with OFFLOAD_CONCURRENCY changed locally, 5 runs each:
| limit | result |
|---|---|
| 7 | fails 5/5 (never reaches 8) |
| 8 | passes 5/5 |
| 9 | passes 5/5 |
| 12 | passes 5/5 |
So raising or dropping the cap would no longer be caught. The 20 ms timer version did catch that, since all workers started inside the window.
Suggested fix: keep the barrier, but hold the eight a moment before releasing them. A correct limit can never exceed 8 however long they wait, so the hold cannot flake, and an over-limit worker has time to start and raise peak:
if (inFlight === 8 || started === clips.length) {
const release = parked;
parked = [];
// Held a moment first: an upload past the eighth would start now and raise the peak.
setTimeout(() => release.forEach((go) => go()), 50);
}With that change locally: limit 8 passes 10/10, limit 9 fails 3/3, limit 12 fails 3/3. The rest of offload.test.ts passes (48/48).
Need ✅ · Size ✅ · Reuse ✅ · Simpler ✅ · Structure ❌ (the cap test passes at any limit ≥ 8) · Risk: low once the hold is in
— Rames
|
Taken as you suggested, at On a Linux box: limit 8 passes 30 runs of 30. With |
jrusso1020
left a comment
There was a problem hiding this comment.
Re-review at b4d3437c: my upper-bound finding from 1ccbb7a6 is resolved.
What changed: the only change since 1ccbb7a6 is offload.test.ts (+4/−2). Once eight uploads are parked, they are released after a 50 ms hold. With a cap above eight, a ninth upload starts during that hold and raises the peak, so the test now fails at a cap that is too high.
Verified: I measured this exact change on the previous head:
- cap 8: passes 10/10;
- caps 9 and 12: fail 3/3 each.
Cap 7 fails by construction: the peak never reaches eight, and the release on the last start leaves peak at 7. All 70 checks on this head pass, including the repeat gate that caught the earlier flake.
Need ✅ · Size ✅ · Reuse ✅ · Simpler ✅ · Structure ✅
Risk: low (test-only delta).
— Rames
* chore: release v0.9.55 * chore: release v0.9.55 notes include heygen-com#7830 * chore: release v0.9.55 notes include heygen-com#7859 and heygen-com#7867 * chore: release v0.9.55 notes name the docs change and cloud render * chore: release v0.9.55 notes include heygen-com#7866 and heygen-com#7801 * chore: release v0.9.55 notes match the style bar
What
cloud renderno longer refuses a project cut from many short clips. When the files the film uses fit under the 200 MB upload limit, they go as one zip with no per-file uploads. When they do not, media nothing names is left out first, then the largest media files the film uses go up as HeyGen assets, eight at a time, just enough for the rest to fit. A project that fits is sent whole, so frames a script loads by a built path ("frames/frame_" + i + ".png") still reach the render.Why
Only media of 5 MB or more ever left the zip. A project of 176 clips, stills and sounds of 3 to 10 MB each kept about 229 MB of them in the zip and was refused with "Project too large for cloud render", even though nothing in it was large. The person was then asked to move files to HeyGen assets by hand.
Timed on a dev account from a Linux box, uploads only, no render:
Each upload costs about a second of requests whatever its size, so one zip is the fastest path and only what does not fit should leave it. On that 176-file project's shape (its file names and sizes, every media file played by the page):
Totals include building the zip.
Related work
None.
How
offloadHeavyMediatakeszipBudgetBytes. Only while the zip is over it: media no page, script or variable names leaves first, largest first; then used media uploads, largest first, counting the staged bytes each one takes out of the zip.cloud renderpasses 95% of the upload limit, which leaves room for the zip's own records. Without a budget, every used media file goes up, as the tests use it.runWithConcurrencyLimit. Each upload keeps its own retries. Two files with the same bytes share one upload. After the first failure the helper starts nothing new and rejects only once the started work has finished, sooffloadHeavyMedianever deletes a temp copy an upload is still reading. Its other callers (lambda batch render, snapshot, the registry resolver) get the same guarantee.Test plan
New tests, red on main and green on this branch (3 runs in a row, Linux):
offload.test.ts: "with no zip budget, uploads every media file a page uses whatever its size, and leaves unused media out"; "uploads up to eight files at once"; "uploads two files with the same bytes once when both start together"; "with a zip budget › uploads nothing and keeps every file when the zip fits"; "with a zip budget › uploads the largest files first, only until the rest fits"; "with a zip budget › keeps frames a script loads by a built path when the zip fits" (red on the first head of this PR too: onlyindex.htmlwas left).render-batch.test.ts: "after a rejection starts nothing new and settles only once started work has finished".Existing tests that pinned the old 5 MB floor now say it as a budget: four pass a 1 MiB budget, so their tiny stand-ins stay in the zip as before. One compares the asset ids as a set, since uploads run together.
offload.test.ts: 48 of 48 pass.render-batch.test.ts: 16 of 16 pass.Every other test that reads a changed file passes: all of
commands/cloud/*.test.ts(one dry-run test now says the new rule: a project that fits keeps its clip in the zip, plans no uploads and leaves an unused take out; 3 runs) andregistry/resolver.test.ts(23 of 23). oxfmt and oxlint are clean on the changed files. The CLI typecheck shows no error in them; the box's checkout lacks a built@hyperframes/inspector, so three unrelated files fail there, and CI runs the full typecheck.fails without the fix: the new offload tests and the new concurrency test, above.
fallow auditagainst the merge base passes on the devbox; its two remaining CRAP findings (planFile,prepareLocalArchive) are on main already, andplanFile's went down (79.4 to 71.3).