Bonjour: ignore ciao cancellation rejections

This commit is contained in:
Emanuel Stadler
2026-01-07 20:35:19 +01:00
committed by Peter Steinberger
parent d6608196d4
commit 9056e0edbb
2 changed files with 20 additions and 0 deletions

View File

@@ -2,6 +2,7 @@ import os from "node:os";
import { logDebug, logWarn } from "../logger.js";
import { getLogger } from "../logging.js";
import { registerUnhandledRejectionHandler } from "./unhandled-rejections.js";
export type GatewayBonjourAdvertiser = {
stop: () => Promise<void>;
@@ -143,6 +144,22 @@ export async function startGatewayBonjourAdvertiser(
});
}
let ciaoCancellationRejectionHandler: (() => void) | undefined;
if (services.length > 0) {
ciaoCancellationRejectionHandler = registerUnhandledRejectionHandler(
(reason) => {
const message = formatBonjourError(reason).toUpperCase();
if (!message.includes("CIAO ANNOUNCEMENT CANCELLED")) {
return false;
}
logDebug(
`bonjour: ignoring unhandled ciao rejection: ${formatBonjourError(reason)}`,
);
return true;
},
);
}
logDebug(
`bonjour: starting (hostname=${hostname}, instance=${JSON.stringify(
safeServiceName(instanceName),
@@ -250,6 +267,7 @@ export async function startGatewayBonjourAdvertiser(
/* ignore */
}
}
ciaoCancellationRejectionHandler?.();
try {
await responder.shutdown();
} catch {