From a6ff7b7fb570d51519d7f1253a1302858885c718 Mon Sep 17 00:00:00 2001 From: Daniel Samson <12231216+daniel-samson@users.noreply.github.com> Date: Sun, 12 Apr 2026 15:18:54 +0100 Subject: [PATCH] =?UTF-8?q?Stop=20workspace=20before=20deleting=20?= =?UTF-8?q?=E2=80=94=20Coder=20returns=20405=20on=20running=20workspaces?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The DELETE API requires the workspace to be stopped first. Now stops, waits 10s for shutdown, then deletes. This was causing workspaces to never be cleaned up after task completion. Co-Authored-By: Claude Opus 4.6 --- src/queue.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/queue.ts b/src/queue.ts index cc09e36..0c6d7c4 100644 --- a/src/queue.ts +++ b/src/queue.ts @@ -127,10 +127,14 @@ export class TaskQueue { this.active.delete(workspaceName); try { + await this.coder.stopWorkspace(entry.workspaceId); + console.log(`[queue] workspace stopped: ${workspaceName} — waiting for shutdown`); + // Wait for the workspace to fully stop before deleting + await new Promise((resolve) => setTimeout(resolve, 10_000)); await this.coder.deleteWorkspace(entry.workspaceId); console.log(`[queue] workspace deleted: ${workspaceName}`); } catch (err) { - console.error(`[queue] failed to delete workspace ${workspaceName}:`, err); + console.error(`[queue] failed to clean up workspace ${workspaceName}:`, err); } // Drain in case pending tasks were waiting for capacity