Repository navigation
fix(studio-server): undo and redo put a file back though Windows holds it for a moment - #6506
Closed
miguel-heygen wants to merge 2 commits into
Closed
miguel-heygen wants to merge 2 commits into
miguel-heygen wants to merge 2 commits into
Conversation
…s it for a moment
Contributor
Edit accuracy: accurate 271 (base branch 271), smooth 143 of thoseThe gate passes. Quarantined, measured but not gated (0) |
Contributor
There was a problem hiding this comment.
Verdict: APPROVE · 0 blocker · 1 important · 1 nit
- important (follow-up): undo of a file add still deletes the project file with a bare
rmSync(projectHistory.ts:1154,writeProjectFile,hash === null). It fails the same way: a holder that does not share delete gets EPERM/EBUSY at once, andrmSync'smaxRetriesis ignored unlessrecursiveis set. So the body's "as every other history write already does" is not true for deletes yet.
Scope
Read all 3 files plus blobStore.ts and writeProjectFile. The only project-file put-back is writeTo → cloneOrCopy. The other renames in blobStore target history-internal blobs, and keep already falls back to a copy. renameWithRetry had one caller, and the argument reorder covers it. Locally: the 3 history suites pass (155) and core atomicFile passes (34). The new test fails with the base blobStore.ts (EPERM). Required CI is green. The optional Comments check is red, see inline.
Merged
2 of 4 tasks
miguel-heygen
enabled auto-merge
October 31, 2026 19:57
Collaborator
Author
auto-merge was automatically disabled
October 31, 2026 21:00
Pull request was closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Undo, redo and restore put a project file back by copying the stored bytes to a temp file and renaming it over the file. That rename now waits out a file Windows holds open for a moment, as every other history write already does.
Why
On Windows, a rename onto a file another process has open (an indexer, antivirus, a preview reading it) fails at once with EPERM, EBUSY or EACCES; the hold clears within milliseconds. The history's own writes (its log, project id, stat file) go through
replaceFileAtomically, which retries those codes. The put-back inblobStore.tscalledrenameSyncdirectly, so an Undo of a held file failed outright.Related work
Refs the Windows held-file fixes in
@hyperframes/engine(renameWithRetry). Core owns this retry: studio-server depends on core, not engine.How
@hyperframes/core/atomic-fileexports its existingrenameWithRetry(from, to, operations?), the onereplaceFileAtomicallyuses;fromandtonow come first, with the fs operations last and optional.blobStore.tscloneOrCopypublishes through it. ThebeforeReplacecheck still runs once, just before the first try.Test plan
projectHistory.heldFile.test.tsrefuses the first rename onto the project's file with EPERM, then checks that Undo and Redo each succeed and leave the right bytes. It fails with the barerenameSync.projectHistory.test.ts,projectHistory.swap.test.ts, the new one): 155 pass. Core'satomicFiletests: 34 pass. The new test passes 3 runs in a row.Size
A lone fix: no open PR of ours touches this code, so it ships on its own.