diff --git a/src/hooks/internal-hooks.test.ts b/src/hooks/internal-hooks.test.ts index c0a87b014bb..a2b51c803c7 100644 --- a/src/hooks/internal-hooks.test.ts +++ b/src/hooks/internal-hooks.test.ts @@ -529,13 +529,15 @@ describe("hooks", () => { expect(event.postHookActions).toEqual([]); }); - it("does not run post-hook actions when no handlers are registered", async () => { + it("drains post-hook actions even when no handlers are registered", async () => { const event = createInternalHookEvent("command", "new", "test-session"); + let ran = false; event.postHookActions.push(() => { - throw new Error("should not run"); + ran = true; }); - // triggerInternalHook returns early when no handlers — post-hooks don't run - await expect(triggerInternalHook(event)).resolves.not.toThrow(); + // No handlers registered — post-hooks should still drain + await triggerInternalHook(event); + expect(ran).toBe(true); }); }); diff --git a/src/hooks/internal-hooks.ts b/src/hooks/internal-hooks.ts index a8d0736fbf0..2feb80e8af1 100644 --- a/src/hooks/internal-hooks.ts +++ b/src/hooks/internal-hooks.ts @@ -279,10 +279,6 @@ export async function triggerInternalHook(event: InternalHookEvent): Promise