perf(test): shorten browser chrome timeout probes

This commit is contained in:
Peter Steinberger
2026-04-20 16:08:55 +01:00
parent 3381e4c375
commit c067c16360
3 changed files with 5 additions and 4 deletions

View File

@@ -178,7 +178,7 @@ async function diagnoseCdpHealthCommand(
: `WebSocket handshake did not complete within ${timeoutMs}ms`,
});
},
Math.max(50, timeoutMs + 25),
Math.max(1, timeoutMs + Math.min(25, timeoutMs)),
);
ws.once("open", () => {

View File

@@ -430,7 +430,7 @@ describe("browser chrome helpers", () => {
// Simulate a stale command channel: WS opens but never responds to commands.
onConnection: (wss) => wss.on("connection", (_ws) => {}),
run: async (baseUrl) => {
await expect(isChromeCdpReady(baseUrl, 300, 150)).resolves.toBe(false);
await expect(isChromeCdpReady(baseUrl, 300, 5)).resolves.toBe(false);
},
});
});
@@ -440,7 +440,7 @@ describe("browser chrome helpers", () => {
wsPath: "/devtools/browser/stale-diagnostic",
onConnection: (wss) => wss.on("connection", (_ws) => {}),
run: async (baseUrl) => {
const diagnostic = await diagnoseChromeCdp(baseUrl, 300, 150);
const diagnostic = await diagnoseChromeCdp(baseUrl, 300, 5);
expect(diagnostic).toMatchObject({
ok: false,
code: "websocket_health_command_timeout",

View File

@@ -433,7 +433,8 @@ export async function stopOpenClawChrome(
if (!(await isChromeReachable(cdpUrlForPort(running.cdpPort), CHROME_STOP_PROBE_TIMEOUT_MS))) {
return;
}
await new Promise((r) => setTimeout(r, 100));
const remainingMs = timeoutMs - (Date.now() - start);
await new Promise((r) => setTimeout(r, Math.max(1, Math.min(100, remainingMs))));
}
try {