fix(e2e): bound kitchen sink readiness probes · openclaw/openclaw@51d0ef8
vincentkoc
·
2026-05-30
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -737,12 +737,15 @@ export async function waitForGatewayReady(child, port, logPath, options = {}) {
|
737 | 737 | throw exitedBeforeReadyError(); |
738 | 738 | } |
739 | 739 | while (Date.now() - started < timeoutMs) { |
| 740 | +const remainingMs = Math.max(1, timeoutMs - (Date.now() - started)); |
740 | 741 | if (hasChildExited(child)) { |
741 | 742 | throw exitedBeforeReadyError(); |
742 | 743 | } |
743 | 744 | try { |
744 | 745 | const readyz = await fetchJson(`http://127.0.0.1:${port}/readyz`, { |
| 746 | +attempts: 1, |
745 | 747 | fetchImpl: options.fetchImpl, |
| 748 | +timeoutMs: Math.min(FETCH_TIMEOUT_MS, remainingMs), |
746 | 749 | }); |
747 | 750 | if (readyz.ok) { |
748 | 751 | return; |
@@ -754,7 +757,8 @@ export async function waitForGatewayReady(child, port, logPath, options = {}) {
|
754 | 757 | if (logReportedReady()) { |
755 | 758 | lastError = `${lastError}; gateway log reported ready before HTTP readiness`; |
756 | 759 | } |
757 | | -await delay(pollDelayMs); |
| 760 | +const nextDelayMs = Math.min(pollDelayMs, Math.max(1, timeoutMs - (Date.now() - started))); |
| 761 | +await delay(nextDelayMs); |
758 | 762 | } |
759 | 763 | if (hasChildExited(child)) { |
760 | 764 | throw new Error(`gateway exited before ready\n${tailFile(logPath)}`); |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -125,6 +125,32 @@ describe("kitchen-sink RPC gateway teardown", () => {
|
125 | 125 | rmSync(root, { recursive: true, force: true }); |
126 | 126 | } |
127 | 127 | }); |
| 128 | + |
| 129 | +it("keeps stalled readiness probes inside the caller deadline", async () => { |
| 130 | +const root = mkdtempSync(path.join(tmpdir(), "openclaw-kitchen-rpc-stalled-ready-")); |
| 131 | +try { |
| 132 | +const logPath = path.join(root, "gateway.log"); |
| 133 | +writeFileSync(logPath, "booting\n"); |
| 134 | +let calls = 0; |
| 135 | +const startedAt = Date.now(); |
| 136 | + |
| 137 | +await expect( |
| 138 | +waitForGatewayReady({ exitCode: null, signalCode: null }, 9, logPath, { |
| 139 | +fetchImpl: () => { |
| 140 | +calls += 1; |
| 141 | +return new Promise(() => {}); |
| 142 | +}, |
| 143 | +pollDelayMs: 1, |
| 144 | +timeoutMs: 25, |
| 145 | +}), |
| 146 | +).rejects.toThrow("gateway did not become ready"); |
| 147 | + |
| 148 | +expect(calls).toBe(1); |
| 149 | +expect(Date.now() - startedAt).toBeLessThan(500); |
| 150 | +} finally { |
| 151 | +rmSync(root, { recursive: true, force: true }); |
| 152 | +} |
| 153 | +}); |
128 | 154 | }); |
129 | 155 | |
130 | 156 | describe("kitchen-sink RPC gateway readiness logs", () => { |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。