Skip to content

Commit 4904e61

Browse files
matej21claude
andcommitted
fix: auto-restart daemon on any compilation failure, not just "Unknown Error"
Bun.build() corruption in long-running daemons can manifest as `{ success: false }` with empty error logs (not just a thrown "Unknown Error"). Broaden the CLI retry logic to restart the daemon on any compilation failure — if the retry also fails, it's a real user error. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 66d66dc commit 4904e61

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

bin/lib/commands/push.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,10 @@ export async function handlePush(args: string[]) {
5555
let result = await response.json() as any;
5656

5757
// Bun.build() can corrupt internal state in long-running daemons,
58-
// returning "Unknown Error, TODO". Restart daemon and retry once.
59-
if (!result.ok && typeof result.error === "string" && result.error.includes("Unknown Error")) {
60-
console.error("Daemon bundler crashed, restarting...");
58+
// causing compilation failures that look like user errors. Restart
59+
// the daemon and retry once — if the retry also fails, it's a real error.
60+
if (!result.ok && result.error === "Canvas compilation failed") {
61+
console.error("Compilation failed, restarting daemon and retrying...");
6162
stopDaemon();
6263
await startDaemon();
6364
const retryResponse = await fetch(`${BASE_URL}/api/session/${sessionId}/plan`, {

daemon/src/compiler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ export async function compilePlan(jsx: string, projectRoot?: string): Promise<Co
166166
.filter((l) => l.level === "error")
167167
.map((l) => l.message)
168168
.join("\n");
169-
return { ok: false, error: errors || "Compilation failed" };
169+
return { ok: false, error: errors || "Bundle failed" };
170170
}
171171

172172
const js = await result.outputs[0].text();

0 commit comments

Comments
 (0)