From ec4c79cb388e685a2470ad0cb8c2c7ffbb618be7 Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Sat, 6 Jun 2026 18:00:47 +0200 Subject: [PATCH] fix(e2e): require kitchen sink ready body --- scripts/e2e/kitchen-sink-rpc-walk.mjs | 4 ++-- test/scripts/kitchen-sink-rpc-walk.test.ts | 24 ++++++++++++++++++++++ 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/scripts/e2e/kitchen-sink-rpc-walk.mjs b/scripts/e2e/kitchen-sink-rpc-walk.mjs index 67d0dd2c7e43..d4c448e99f0c 100644 --- a/scripts/e2e/kitchen-sink-rpc-walk.mjs +++ b/scripts/e2e/kitchen-sink-rpc-walk.mjs @@ -994,10 +994,10 @@ export async function waitForGatewayReady(child, port, logPath, options = {}) { throw outcome.error; } const readyz = outcome.readyz; - if (readyz.ok) { + if (readyz.ok && readyz.body?.ready === true) { return; } - lastError = `/readyz HTTP ${readyz.status}`; + lastError = `/readyz HTTP ${readyz.status} body=${JSON.stringify(readyz.body)}`; } catch (error) { lastError = error instanceof Error ? error.message : String(error); } diff --git a/test/scripts/kitchen-sink-rpc-walk.test.ts b/test/scripts/kitchen-sink-rpc-walk.test.ts index c45fd2058f6b..6864874a91b7 100644 --- a/test/scripts/kitchen-sink-rpc-walk.test.ts +++ b/test/scripts/kitchen-sink-rpc-walk.test.ts @@ -302,6 +302,30 @@ describe("kitchen-sink RPC gateway teardown", () => { rmSync(root, { recursive: true, force: true }); } }); + + it("requires /readyz body.ready before accepting gateway readiness", async () => { + const root = mkdtempSync(path.join(tmpdir(), "openclaw-kitchen-rpc-ready-body-")); + try { + const logPath = path.join(root, "gateway.log"); + writeFileSync(logPath, "[gateway] ready\n"); + const fetchImpl = vi + .fn() + .mockResolvedValueOnce(new Response('{"ready":false}', { status: 200 })) + .mockResolvedValueOnce(new Response('{"ready":true}', { status: 200 })); + + await expect( + waitForGatewayReady({ exitCode: null, signalCode: null }, 9, logPath, { + fetchImpl, + pollDelayMs: 1, + timeoutMs: 100, + }), + ).resolves.toBeUndefined(); + + expect(fetchImpl).toHaveBeenCalledTimes(2); + } finally { + rmSync(root, { recursive: true, force: true }); + } + }); }); describe("kitchen-sink RPC gateway readiness logs", () => {