feat: update agent binaries and restart opencode server during sync#155
Merged
feat: update agent binaries and restart opencode server during sync#155
Conversation
Comment on lines
610
to
614
| private async restartOpenCodeServer(containerName: string): Promise<void> { | ||
| await docker.execInContainer(containerName, ['sh', '-c', 'pkill -f "opencode serve" || true'], { | ||
| user: 'workspace', | ||
| }); | ||
| await this.startOpenCodeServer(containerName); |
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
Comment on lines
+611
to
+621
| await docker.execInContainer( | ||
| containerName, | ||
| [ | ||
| 'sh', | ||
| '-c', | ||
| 'pkill -f "opencode serve" || true; for i in $(seq 1 20); do pgrep -f "opencode serve" > /dev/null || break; sleep 0.25; done', | ||
| ], | ||
| { user: 'workspace' } | ||
| ); | ||
| await this.startOpenCodeServer(containerName); | ||
| } |
There was a problem hiding this comment.
Bug: A race condition in restartOpenCodeServer can cause startOpenCodeServer to silently fail if the old server process takes more than 5 seconds to terminate.
Severity: MEDIUM
Suggested Fix
Increase the timeout in the wait loop from 5 seconds to a more conventional value, such as 10-30 seconds. Additionally, the return value from docker.execInContainer() should be checked. If the script failed to kill the old process in time, an error should be thrown or logged instead of proceeding to call startOpenCodeServer.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.
Location: src/workspace/manager.ts#L610-L621
Potential issue: The `restartOpenCodeServer` function executes a script to kill the
`opencode serve` process and then waits up to 5 seconds for it to terminate. If the
process takes longer than 5 seconds to shut down, the script exits successfully. The
subsequent call to `startOpenCodeServer` then detects the old, still-running process and
exits silently without starting a new one. This causes the intended server binary update
to fail without any notification, making it seem like the operation succeeded when it
did not.
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
perry sync --allnow runs agent binary updates (claude, opencode, pi) in addition to credential/config syncopencode serveprocess and starts a fresh one so it picks up the new binary