mirror of
https://github.com/moltbot/moltbot.git
synced 2026-03-21 16:41:56 +00:00
Infra: ignore ciao probing cancellations
This commit is contained in:
@@ -9,7 +9,7 @@ vi.mock("../logger.js", () => ({
|
||||
const { ignoreCiaoCancellationRejection } = await import("./bonjour-ciao.js");
|
||||
|
||||
describe("bonjour-ciao", () => {
|
||||
it("ignores and logs ciao cancellation rejections", () => {
|
||||
it("ignores and logs ciao announcement cancellation rejections", () => {
|
||||
expect(
|
||||
ignoreCiaoCancellationRejection(new Error("Ciao announcement cancelled by shutdown")),
|
||||
).toBe(true);
|
||||
@@ -18,6 +18,15 @@ describe("bonjour-ciao", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("ignores and logs ciao probing cancellation rejections", () => {
|
||||
logDebugMock.mockReset();
|
||||
|
||||
expect(ignoreCiaoCancellationRejection(new Error("CIAO PROBING CANCELLED"))).toBe(true);
|
||||
expect(logDebugMock).toHaveBeenCalledWith(
|
||||
expect.stringContaining("ignoring unhandled ciao rejection"),
|
||||
);
|
||||
});
|
||||
|
||||
it("ignores lower-case string cancellation reasons too", () => {
|
||||
logDebugMock.mockReset();
|
||||
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
import { logDebug } from "../logger.js";
|
||||
import { formatBonjourError } from "./bonjour-errors.js";
|
||||
|
||||
const CIAO_CANCELLATION_MESSAGE_RE = /^CIAO (?:ANNOUNCEMENT|PROBING) CANCELLED\b/u;
|
||||
|
||||
export function ignoreCiaoCancellationRejection(reason: unknown): boolean {
|
||||
const message = formatBonjourError(reason).toUpperCase();
|
||||
if (!message.includes("CIAO ANNOUNCEMENT CANCELLED")) {
|
||||
if (!CIAO_CANCELLATION_MESSAGE_RE.test(message)) {
|
||||
return false;
|
||||
}
|
||||
logDebug(`bonjour: ignoring unhandled ciao rejection: ${formatBonjourError(reason)}`);
|
||||
|
||||
Reference in New Issue
Block a user