Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions src/infra/bonjour.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -307,4 +307,29 @@ describe("gateway bonjour advertiser", () => {

await started.stop();
});

it("disables Bonjour on win32 unless explicitly enabled", async () => {
enableAdvertiserUnitMode();
vi.spyOn(process, "platform", "get").mockReturnValue("win32");

const started = await startGatewayBonjourAdvertiser({
gatewayPort: 18789,
sshPort: 2222,
});
expect(createService).not.toHaveBeenCalled();
await started.stop();

createService.mockClear();
process.env.OPENCLAW_ENABLE_BONJOUR_WINDOWS = "1";
const destroy = vi.fn().mockResolvedValue(undefined);
const advertise = vi.fn().mockResolvedValue(undefined);
mockCiaoService({ advertise, destroy });

const enabled = await startGatewayBonjourAdvertiser({
gatewayPort: 18789,
sshPort: 2222,
});
expect(createService).toHaveBeenCalledTimes(1);
await enabled.stop();
});
});
8 changes: 8 additions & 0 deletions src/infra/bonjour.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ function isDisabledByEnv() {
if (isTruthyEnvValue(process.env.OPENCLAW_DISABLE_BONJOUR)) {
return true;
}
// On Windows, ciao's network probing can spawn visible cmd.exe helpers on some
// hosts. Keep Bonjour opt-in there to avoid periodic console-window flashing.
if (
process.platform === "win32" &&
!isTruthyEnvValue(process.env.OPENCLAW_ENABLE_BONJOUR_WINDOWS)
) {
return true;
}
if (process.env.NODE_ENV === "test") {
return true;
}
Expand Down
Loading