Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions .github/workflows/mobile-e2e.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
name: Mobile E2E Tests

on:
push:
branches: [main]
paths:
- 'mobile/**'
pull_request:
branches: [main]
paths:
- 'mobile/**'
workflow_dispatch:
schedule:
- cron: '0 9 * * 1' # Monday 9am UTC

jobs:
maestro-ios:
Expand Down
20 changes: 19 additions & 1 deletion src/workspace/manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,19 @@ export class WorkspaceManager {
}
}

private async restartOpenCodeServer(containerName: string): Promise<void> {
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);
Comment on lines +610 to +620

This comment was marked as outdated.

}
Comment on lines +611 to +621
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.


private async runUserScripts(containerName: string): Promise<void> {
const scriptPaths = this.config.scripts.post_start;
if (!scriptPaths || scriptPaths.length === 0) {
Expand Down Expand Up @@ -1221,7 +1234,12 @@ export class WorkspaceManager {
throw new Error(`Workspace '${name}' is not running`);
}

await this.setupWorkspaceCredentials(containerName, name, { strictWorker: true });
await this.setupWorkspaceCredentials(containerName, name, {
strictWorker: true,
startOpenCodeServer: false,
});
await this.updateAgentBinaries(containerName);
await this.restartOpenCodeServer(containerName);
Comment on lines +1241 to +1242

This comment was marked as outdated.

}

async setPortForwards(name: string, forwards: PortMapping[]): Promise<Workspace> {
Expand Down
Loading