fix: keep unhandled rejections safe

This commit is contained in:
Shadow
2026-01-27 16:48:14 -06:00
committed by Shadow
parent 3b879fe524
commit 3a25a4fa99

View File

@@ -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", () => {