Handle stale workspaces: 409 conflict auto-cleanup + verbose logging
Publish Image / publish (push) Successful in 20s

When the orchestrator restarts, it loses in-memory queue state. If a
stale workspace still exists, createWorkspace now auto-deletes it and
retries instead of failing with 409. Also adds --verbose to Claude Code
invocation for better task log debugging.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Daniel Samson
2026-04-12 13:58:08 +01:00
co-authored by Claude Opus 4.6
parent 4f1d306fdf
commit 06cf4d1b9e
2 changed files with 16 additions and 2 deletions
+4 -2
View File
@@ -579,8 +579,10 @@ LOGEOF
ARGS="$DEPLOY_ENV" ARGS="$DEPLOY_ENV"
fi fi
# Run Claude Code in non-interactive mode # Run Claude Code in non-interactive mode with tool access
claude --print --dangerously-skip-permissions "/project:$TASK_TYPE $ARGS" 2>&1 | tee ~/task-output.log claude -p --dangerously-skip-permissions --verbose "/project:$TASK_TYPE $ARGS" 2>&1 | tee ~/task-output.log
EXIT_CODE=$?
echo "Claude exited with code: $EXIT_CODE" | tee -a ~/task-output.log
echo "Task completed. Output saved to ~/task-output.log" echo "Task completed. Output saved to ~/task-output.log"
+12
View File
@@ -50,6 +50,18 @@ export class CoderClient {
}, },
); );
// Handle 409 conflict — stale workspace from a previous orchestrator instance
if (res.status === 409) {
console.log(`[coder] workspace "${name}" already exists — deleting stale workspace and retrying`);
const existing = await this.findWorkspaceByName(name);
if (existing) {
await this.deleteWorkspace(existing.id);
// Wait for deletion to propagate
await new Promise((resolve) => setTimeout(resolve, 5000));
}
return this.createWorkspace(task);
}
if (!res.ok) { if (!res.ok) {
const text = await res.text(); const text = await res.text();
throw new Error(`Coder API error ${res.status}: ${text}`); throw new Error(`Coder API error ${res.status}: ${text}`);