fix(qa): clamp gateway restart polling · openclaw/openclaw@5de0d87
steipete
·
2026-05-31
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -434,6 +434,17 @@ describe("buildQaRuntimeEnv", () => {
|
434 | 434 | ).rejects.toThrow("qa gateway child did not reach restart boundary"); |
435 | 435 | }); |
436 | 436 | |
| 437 | +it("keeps oversized restart-boundary poll intervals within the timeout", async () => { |
| 438 | +await expect( |
| 439 | +testing.waitForQaGatewayRestartBoundary({ |
| 440 | +logs: () => "signal SIGUSR1 received\n", |
| 441 | +offset: 0, |
| 442 | +pollMs: Number.MAX_SAFE_INTEGER, |
| 443 | +timeoutMs: 5, |
| 444 | +}), |
| 445 | +).rejects.toThrow("qa gateway child did not reach restart boundary"); |
| 446 | +}); |
| 447 | + |
437 | 448 | it("stages a live Anthropic setup-token profile for isolated QA workers", async () => { |
438 | 449 | const stateDir = await mkdtemp(path.join(os.tmpdir(), "qa-setup-token-state-")); |
439 | 450 | cleanups.push(async () => { |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -8,6 +8,7 @@ import path from "node:path";
|
8 | 8 | import { setTimeout as sleep } from "node:timers/promises"; |
9 | 9 | import type { OpenClawConfig } from "openclaw/plugin-sdk/config-contracts"; |
10 | 10 | import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime"; |
| 11 | +import { resolveTimerTimeoutMs } from "openclaw/plugin-sdk/number-runtime"; |
11 | 12 | import type { ModelProviderConfig } from "openclaw/plugin-sdk/provider-model-shared"; |
12 | 13 | import { fetchWithSsrFGuard } from "openclaw/plugin-sdk/ssrf-runtime"; |
13 | 14 | import { |
@@ -306,13 +307,17 @@ async function waitForQaGatewayRestartBoundary(params: {
|
306 | 307 | timeoutMs?: number; |
307 | 308 | }) { |
308 | 309 | const timeoutMs = params.timeoutMs ?? QA_GATEWAY_CHILD_RESTART_BOUNDARY_TIMEOUT_MS; |
309 | | -const pollMs = params.pollMs ?? 100; |
| 310 | +const pollMs = resolveTimerTimeoutMs(params.pollMs ?? 100, 100, 0); |
310 | 311 | const startedAt = Date.now(); |
311 | 312 | while (Date.now() - startedAt < timeoutMs) { |
312 | 313 | if (params.logs().slice(params.offset).includes("restart mode:")) { |
313 | 314 | return; |
314 | 315 | } |
315 | | -await sleep(pollMs); |
| 316 | +const remainingMs = timeoutMs - (Date.now() - startedAt); |
| 317 | +if (remainingMs <= 0) { |
| 318 | +break; |
| 319 | +} |
| 320 | +await sleep(Math.min(pollMs, remainingMs)); |
316 | 321 | } |
317 | 322 | throw new Error(`qa gateway child did not reach restart boundary within ${timeoutMs}ms`); |
318 | 323 | } |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。