fix: parse matrix no-reply window strictly · openclaw/openclaw@490c226
steipete
·
2026-05-29
·
via Recent Commits to openclaw:main
File tree
extensions/qa-matrix/src/runners/contract
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +import { afterEach, describe, expect, it, vi } from "vitest"; |
| 2 | +import { resolveMatrixQaNoReplyWindowMs } from "./scenario-runtime-shared.js"; |
| 3 | + |
| 4 | +describe("matrix scenario runtime shared", () => { |
| 5 | +afterEach(() => { |
| 6 | +vi.unstubAllEnvs(); |
| 7 | +}); |
| 8 | + |
| 9 | +it("normalizes the Matrix QA no-reply window env", () => { |
| 10 | +expect(resolveMatrixQaNoReplyWindowMs(30_000)).toBe(8_000); |
| 11 | + |
| 12 | +vi.stubEnv("OPENCLAW_QA_MATRIX_NO_REPLY_WINDOW_MS", "12000"); |
| 13 | +expect(resolveMatrixQaNoReplyWindowMs(30_000)).toBe(12_000); |
| 14 | +expect(resolveMatrixQaNoReplyWindowMs(5_000)).toBe(5_000); |
| 15 | + |
| 16 | +for (const value of ["1e3", "0x1000", "1.5", "nope"]) { |
| 17 | +vi.stubEnv("OPENCLAW_QA_MATRIX_NO_REPLY_WINDOW_MS", value); |
| 18 | +expect(resolveMatrixQaNoReplyWindowMs(30_000)).toBe(8_000); |
| 19 | +} |
| 20 | +}); |
| 21 | +}); |
| Original file line number | Diff line number | Diff line change |
|---|
@@ -65,9 +65,10 @@ const NO_REPLY_WINDOW_MS = 8_000;
|
65 | 65 | const NO_REPLY_WINDOW_ENV = "OPENCLAW_QA_MATRIX_NO_REPLY_WINDOW_MS"; |
66 | 66 | |
67 | 67 | export function resolveMatrixQaNoReplyWindowMs(timeoutMs: number) { |
68 | | -const raw = process.env[NO_REPLY_WINDOW_ENV]; |
69 | | -const parsed = raw === undefined ? NO_REPLY_WINDOW_MS : Number(raw); |
70 | | -const windowMs = Number.isFinite(parsed) && parsed >= 1 ? Math.floor(parsed) : NO_REPLY_WINDOW_MS; |
| 68 | +const raw = process.env[NO_REPLY_WINDOW_ENV]?.trim(); |
| 69 | +const parsed = |
| 70 | +raw === undefined ? NO_REPLY_WINDOW_MS : /^\d+$/.test(raw) ? Number(raw) : Number.NaN; |
| 71 | +const windowMs = Number.isSafeInteger(parsed) && parsed >= 1 ? parsed : NO_REPLY_WINDOW_MS; |
71 | 72 | return Math.min(windowMs, timeoutMs); |
72 | 73 | } |
73 | 74 | |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。