From 85294f19f70c7fb178a58b90c7b396eeec0f4f2d Mon Sep 17 00:00:00 2001 From: AyedAlmudarra Date: Fri, 30 Jan 2026 12:11:19 +0300 Subject: [PATCH] test: add mDNS error handling tests Add tests for new mDNS/Bonjour error handling: - IPv4 address change errors (AssertionError) - MDNSServer illegal state errors Verifies fixes for #3821 - gateway no longer crashes on mDNS errors --- ...handled-rejections.fatal-detection.test.ts | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/infra/unhandled-rejections.fatal-detection.test.ts b/src/infra/unhandled-rejections.fatal-detection.test.ts index e991c67c9..275d861c9 100644 --- a/src/infra/unhandled-rejections.fatal-detection.test.ts +++ b/src/infra/unhandled-rejections.fatal-detection.test.ts @@ -158,5 +158,32 @@ describe("installUnhandledRejectionHandler - fatal detection", () => { expect(exitCalls).toEqual([]); expect(consoleWarnSpy).toHaveBeenCalled(); }); + + it("does NOT exit on mDNS/Bonjour IPv4 address change errors", () => { + const mdnsErr = Object.assign( + new Error("Reached illegal state! IPv4 address changed from undefined to defined!"), + { + name: "AssertionError", + code: "ERR_ASSERTION", + }, + ); + + process.emit("unhandledRejection", mdnsErr, Promise.resolve()); + + expect(exitCalls).toEqual([]); + expect(consoleWarnSpy).toHaveBeenCalledWith( + "[openclaw] Non-fatal unhandled rejection (continuing):", + expect.stringContaining("IPv4 address changed"), + ); + }); + + it("does NOT exit on mDNS MDNSServer illegal state errors", () => { + const mdnsErr = new Error("MDNSServer: Reached illegal state during network update"); + + process.emit("unhandledRejection", mdnsErr, Promise.resolve()); + + expect(exitCalls).toEqual([]); + expect(consoleWarnSpy).toHaveBeenCalled(); + }); }); });