mirror of https://github.com/openclaw/openclaw.git
Infra: ignore ciao probing cancellations
This commit is contained in:
parent
13894ec5aa
commit
8a226fffb4
|
|
@ -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)}`);
|
||||
|
|
|
|||
Loading…
Reference in New Issue