From ecc495f9e8eb0e97ee53c6978e17df0319fb9cde Mon Sep 17 00:00:00 2001 From: Proactive Runtime Bot Date: Tue, 22 Sep 2026 18:56:36 -0700 Subject: [PATCH] test(relayflows): stop the readiness probe dying on "broker is starting" The muse-unattended-startup case builds its `api()` helper around `await response.json()`, so the body was parsed before any caller looked at the status. The broker answers `Broker is starting, please retry` as plain text while it comes up -- precisely what the readiness probe is waiting to stop seeing -- so the parse threw, the rejection escaped `waitFor`, and the whole case failed on a startup race rather than retrying. The helper now reads the body as text and parses it only if it is JSON, keeping the raw text as the body so an assertion message still shows what came back. `broker-local-only` already survives this by wrapping its probe in try/catch; this fixes the cause instead, so every call site benefits. Co-Authored-By: Claude Opus 5 --- .../cases/muse-unattended-startup/run.mjs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/tests/relayflows/cases/muse-unattended-startup/run.mjs b/tests/relayflows/cases/muse-unattended-startup/run.mjs index d1dd9033a..0cfd3aeb6 100644 --- a/tests/relayflows/cases/muse-unattended-startup/run.mjs +++ b/tests/relayflows/cases/muse-unattended-startup/run.mjs @@ -179,7 +179,19 @@ sleep 60 body: body === undefined ? undefined : JSON.stringify(body), signal: AbortSignal.timeout(10_000), }); - return { status: response.status, body: await response.json() }; + // The broker answers `Broker is starting, please retry` as plain text + // before its API is up -- exactly what the readiness probe below waits to + // stop seeing. Parsing unconditionally threw out of the probe instead of + // letting it retry, failing the case on a startup race. Keep the raw text + // as the body so an assertion message still shows what came back. + const text = await response.text(); + let parsed; + try { + parsed = JSON.parse(text); + } catch { + parsed = text; + } + return { status: response.status, body: parsed }; }; await waitFor( () => api('GET', '/api/session').then(({ status }) => status === 200),