fix: Windows-safe atomic session state writes (EPERM) - #5
Merged
Merged
Conversation
OpenCode Loop rewrites .opencode/opencode-loop/ses_*.json on every heartbeat and due-timer tick. On Windows, rename over an existing state file often fails with EPERM/EEXIST while antivirus, IDE indexers, or OpenCode snapshots hold the destination. Project-local *.tmp files also leaked into git snapshot pathspecs. Stage payloads in the OS temp directory, replace the target with rename when possible, and fall back to copy/unlink with short retries. Add a regression for rapid state overwrites and document gitignore guidance.
Owner
|
thank you for contribution |
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.
Summary
Fixes
/loopbreaking on Windows when heartbeat and due-timer updates rewrite session state.On Windows, OpenCode Loop was writing state as:
.opencode/opencode-loop/ses_*.json.<pid>.<ts>.tmpnext to the targetrename(tmp, target)That fails with
EPERM/EEXISTwhen antivirus, IDE indexers, or OpenCode's own git snapshotter briefly hold the destination file. Observed effects in production logs:heartbeat-error/due-timer-errorwithEPERM: operation not permitted, rename ...tmp -> ...jsonjobs: [])failed to add snapshot filesfor project-local*.tmppathspecsChanges
renamewhen possiblecopyFile+ unlink with short retries onEXDEV/EPERM/EEXIST/EBUSY/EACCES*.tmp.gitignoreguidance for.opencode/opencode-loop/Test plan
npm test(installer, loopd, smoke, comprehensive) on Windows/loop 0s --max-runs 3 continue from progress.md/loop-statusshows the job across heartbeat ticksEPERMlines in.opencode/opencode-loop/loop.logopencode-loop/*.tmpleft in the project treeNotes
This is independent of
opencode-ralph-loopload failures (content.match is not a function); that is a separate package.