Skip to content

fix(studio-server): two exports in the same second get separate jobs - #7053

Merged
miguel-heygen merged 2 commits into
mainfrom
fix/render-job-id-unique
Nov 3, 2026
Merged

miguel-heygen merged 2 commits into
mainfrom
fix/render-job-id-unique

Conversation

@miguel-heygen

Copy link
Copy Markdown
Collaborator

What

Two exports of one project started in the same second now get their own job and their own output file. The second takes a -2 suffix (then -3, and so on) when the id is already a running job or its file already exists.

Why

POST /api/projects/:id/render built the job id as the project id plus a timestamp with one-second resolution, and that id is also the output file name. Two exports within a second shared a key in the server's job map, so the second replaced the first job and both wrote the same file. The id is minted in one place, packages/studio-server/src/routes/render.ts. A single export keeps the same id and file name as before.

Testing

fails without the fix: packages/studio-server/src/routes/render.test.ts > "gives two exports started in the same second their own job and output file"

On the devbox: 90 passed in render.test.ts, 3 runs in a row; with the old render.ts the new test fails (1 failed, 89 passed).

Size

A short change to one id and its test; it has no other carrier.

@heygengenesis heygengenesis Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requesting changes on e369f3e1 for one thing: the Comments check fails because of this diff.

RAISED comment share: packages/studio-server/src/routes/render.ts is 10.9% (45/414), at the base 10.5% (43/409) — 2 comment line(s) added.

The ratchet won't let a file's comment share go up, and the new two-line comment above baseId is what pushes it over. Delete the comment, or move what it says into a name, for example a small nextFreeRenderJobId(baseId, ext) helper. Once that check passes, I don't see another blocker.

The rest checks out:

  • Fix: the id is chosen and renderJobs.set runs in the same synchronous step (adapter.startRender returns synchronously and nothing is awaited in between), so two concurrent POSTs can't both get the same id. Checking for an existing ${jobId}${ext} also stops a file from a restarted session being overwritten. A single export keeps its old id and file name.
  • Consumers: nothing in studio/studio-server parses the timestamp back out of the id. The list, delete, view and download routes key on the full id, so a -2 suffix works with all of them.
  • Fails without the fix: I confirmed it locally. At head, render.test.ts has 90 passing, two runs in a row. With the base render.ts and the new test, the named test fails (expected 1 to be 2, 1 failed / 89 passed).

@github-actions

github-actions Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Edit accuracy: accurate 267 (base branch 267), smooth 97 of those

The gate passes.
Smoothness is reported in the artifact, not gated. A case fails only if it fails 2 of 3 runs.

Quarantined, measured but not gated (8)

Unstable (1)

  • seqfastkeys-none-px-r0-root-z100: tracking 0.07, pressJump 0.05, drop 0, reload 0, render 0.02, renderKey -, undo false, teleport true / tracking 0.06, pressJump 0.05, drop 0, reload 0, render 0.02, renderKey -, undo true, teleport true / tracking 0.06, pressJump 0.05, drop 0, reload 0, render 0.02, renderKey -, undo true, teleport true

@heygengenesis heygengenesis Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving at e7c88ab3. The only blocker from the last review is resolved: the comment is now a named helper, nextFreeRenderJobId, and the Comments check passes on this head.

The change since e369f3e1 only moves the loop into that helper. It works the same way, and the id is still chosen and stored in the same synchronous step, with nothing awaited in between.

I reran the named test on this head. render.test.ts passes 90/90. With the base render.ts, "gives two exports started in the same second their own job and output file" fails (1 failed / 89 passed).

@miguel-heygen
miguel-heygen added this pull request to the merge queue Nov 3, 2026
Merged via the queue into main with commit 92943d9 Nov 3, 2026
82 checks passed
@miguel-heygen
miguel-heygen deleted the fix/render-job-id-unique branch November 3, 2026 01:32
@jrusso1020 jrusso1020 mentioned this pull request Nov 3, 2026
SanHsien added a commit to SanHsien/hyperframes that referenced this pull request Nov 4, 2026
Ports upstream heygen-com#7053 (92943d9): when a render job id derived from the
second-resolution timestamp is already taken in memory or on disk, append
a numeric suffix instead of overwriting the earlier output. Adds a
regression test that failed on the old code.

Also records the 2026-11-02 upstream review pass: 14 consecutive commits
judged with file:line evidence and the commit baseline advanced to
4c1c178; the remaining range is kept in ROADMAP.

Co-authored-by: Miguel Ángel <miguel.sierra@heygen.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant