host tests: agent-host's readiness probe gives up on a host that never answers (#5577)

startHost() in tests/agent-host.test.mjs polled /api/agent/status with fetch() and
no timeout. undici waits up to 300 s for headers, so a host that accepted the
connection but never answered kept the loop on one await: neither its 20 s budget
nor its exit check ran, and the run hung until the runner's global timeout, without
the host's log. Each attempt now ends within 2 s (AbortSignal.timeout, as
host-lifecycle and app-ui already do); the abort lands in the existing catch.
Test: agent-host.test.mjs runs as before (its cases need a built Harness here).
This commit is contained in:
Niko1221 committed 2026-11-16 16:55:40 +01:00
1 parent 4864a4daa5
commit 937fe71155
1 file changed
+2 -1
+2 -1
View File
@@ -40,7 +40,8 @@ async function startHost(t, { home, ws, harness = HARNESS } = {}) {
t.after(stop);
const base = `http://127.0.0.1:${port}`;
for (let i = 0; i < 100; i++) {
try { if ((await fetch(`${base}/api/agent/status`)).ok) break; } catch { /* not up yet */ }
// #5577: each attempt ends within 2 s, so a host that accepts the connection but never answers fails with its log instead of hanging
try { if ((await fetch(`${base}/api/agent/status`, { signal: AbortSignal.timeout(2000) })).ok) break; } catch { /* not up yet, or no answer in time */ }
if (child.exitCode !== null) throw new Error(`the host exited: ${log.slice(-500)}`);
await sleep(200);
}