From 026f804b4862d520821a931393d126d4f8d17f04 Mon Sep 17 00:00:00 2001 From: "Doink (OpenClaw)" Date: Wed, 25 Feb 2026 15:21:13 -0800 Subject: [PATCH] fix: make on-create hook defaults sane Increase default hook timeout from 60s to 300s for large monorepo installs. Make hook failures throw instead of being silently swallowed, so a failed on-create hook aborts the launch rather than starting the agent in a broken worktree. Fixes #55 Co-Authored-By: Charlie Hulcher Co-Authored-By: Claude Opus 4.6 --- src/hooks.test.ts | 14 +++++++------- src/hooks.ts | 5 ++--- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/hooks.test.ts b/src/hooks.test.ts index ef9494b..3ad3dc9 100644 --- a/src/hooks.test.ts +++ b/src/hooks.test.ts @@ -94,14 +94,14 @@ describe("runHook", () => { expect(result?.stdout.trim()).toBe("claude-opus-4-6"); }); - it("handles hook script failures gracefully", async () => { + it("throws when hook script fails", async () => { const hooks: LifecycleHooks = { onCreate: "exit 1" }; - const result = await runHook(hooks, "onCreate", { - ...defaultCtx, - cwd: tmpDir, - }); - // Should not throw, returns result with stderr - expect(result).not.toBeNull(); + await expect( + runHook(hooks, "onCreate", { + ...defaultCtx, + cwd: tmpDir, + }), + ).rejects.toThrow("Hook onCreate failed:"); }); it("runs onComplete hook", async () => { diff --git a/src/hooks.ts b/src/hooks.ts index 12aa621..7bb1e1d 100644 --- a/src/hooks.ts +++ b/src/hooks.ts @@ -47,12 +47,11 @@ export async function runHook( const result = await execAsync(script, { cwd: ctx.cwd, env, - timeout: 60_000, + timeout: 300_000, }); return { stdout: result.stdout, stderr: result.stderr }; } catch (err) { const e = err as Error & { stdout?: string; stderr?: string }; - console.error(`Hook ${phase} failed:`, e.message); - return { stdout: e.stdout || "", stderr: e.stderr || "" }; + throw new Error(`Hook ${phase} failed: ${e.message}`); } }