From 3a25a4fa998e2f919b1bd201d43ee5feb917a066 Mon Sep 17 00:00:00 2001 From: Shadow Date: Tue, 27 Jan 2026 16:48:14 -0600 Subject: [PATCH] fix: keep unhandled rejections safe --- src/infra/unhandled-rejections.fatal-detection.test.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/infra/unhandled-rejections.fatal-detection.test.ts b/src/infra/unhandled-rejections.fatal-detection.test.ts index 7c8d97675..b9ff4557b 100644 --- a/src/infra/unhandled-rejections.fatal-detection.test.ts +++ b/src/infra/unhandled-rejections.fatal-detection.test.ts @@ -125,13 +125,16 @@ describe("installUnhandledRejectionHandler - fatal detection", () => { expect(consoleWarnSpy).toHaveBeenCalled(); }); - it("does NOT exit on generic errors without code", () => { + it("exits on generic errors without code", () => { const genericErr = new Error("Something went wrong"); process.emit("unhandledRejection", genericErr, Promise.resolve()); - expect(exitCalls).toEqual([]); - expect(consoleWarnSpy).toHaveBeenCalled(); + expect(exitCalls).toEqual([1]); + expect(consoleErrorSpy).toHaveBeenCalledWith( + "[clawdbot] Unhandled promise rejection:", + expect.stringContaining("Something went wrong"), + ); }); it("does NOT exit on connection reset errors", () => {