GeezerVison is showing github.com — fix(cli): retry service file renames on Windows by Hona · Pull Request #59105 · anomalyco/opencode
Conversation
Hona
commented
Oct 25, 2026
•
edited by opencode-agent
Bot
Loading
Uh oh!
There was an error while loading. Please reload this page.
Backport of the service file fixes in #57277 (Kit Langton) from beta.
Problem
- Service config: every write staged
<config>.tmp and renamed it over the config. Two CLI commands writing at once, such as two opencode service set calls, shared that temp file and could corrupt it.
- Windows: a rename fails with
EPERM while another process has the target open, for example a client reading service.json or a contender starting.
Change
- Config write: stages
<config>.<pid>.tmp, so concurrent writers never share a temp file, and retries the rename up to 20 times, 10 ms apart.
- Registration write: already staged a per-service temp file; it now retries its rename the same way.
- Test isolation: the service test clears
OPENCODE_CONFIG_DIR, so a developer's own config cannot leak into it.
Who runs the service is still decided by the port bind alone; only the elected server writes service.json.
Testing
typecheck:tsc passes in cli.
cli/test/service.test.ts passes.
Added by the opencode bot (AI-generated).
Related: #56746
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Backport of the service file fixes in #57277 from beta. Two CLI commands
writing the service config at once shared one temp file, and on Windows a
rename fails with EPERM while another process has the target open. The config
write now stages a per-process temp file, and both it and the registration
write retry the rename briefly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The change is sound. On Linux I reproduced the shared <config>.tmp race on the base: with 12 concurrent opencode service set calls, one run failed with NotFound: FileSystem.rename (…service-local.json.tmp). With this PR, repeated runs gave no failures and left no temp files behind. I couldn't exercise the Windows EPERM retry path here. test/service.test.ts passes (28 pass, 1 skip) and typecheck:tsc passes in packages/cli.
The public API is unchanged.
No blocking concerns.
Related: #56746
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
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.
|