diff --git a/src/commands/health.snapshot.test.ts b/src/commands/health.snapshot.test.ts index de5a427007e..ba7ca3f5f87 100644 --- a/src/commands/health.snapshot.test.ts +++ b/src/commands/health.snapshot.test.ts @@ -5,6 +5,7 @@ import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vite import type { ChannelAccountSnapshot } from "../channels/plugins/types.js"; import type { ChannelPlugin } from "../channels/plugins/types.js"; import { createPluginRecord } from "../plugins/status.test-helpers.js"; +import { MAX_TIMER_TIMEOUT_MS } from "../shared/number-coercion.js"; import type { HealthSummary } from "./health.js"; let testConfig: Record = {}; @@ -474,6 +475,23 @@ describe("getHealthSnapshot", () => { vi.unstubAllEnvs(); }); + it("clamps oversized probe timeouts", async () => { + testConfig = { + session: { store: "/tmp/x" }, + channels: { telegram: { botToken: "123:test" } }, + }; + testStore = {}; + const timeouts: number[] = []; + probeTelegramAccountForTestOverride = async (_account, timeoutMs) => { + timeouts.push(timeoutMs); + return { ok: true }; + }; + + await getHealthSnapshot({ timeoutMs: Number.MAX_SAFE_INTEGER }); + + expect(timeouts).toEqual([MAX_TIMER_TIMEOUT_MS]); + }); + it("includes active plugin load errors in the health snapshot", async () => { testConfig = { session: { store: "/tmp/x" } }; testStore = {}; diff --git a/src/commands/health.ts b/src/commands/health.ts index fc125c5cc90..66329b0326a 100644 --- a/src/commands/health.ts +++ b/src/commands/health.ts @@ -1,3 +1,4 @@ +import { resolveTimerTimeoutMs } from "@openclaw/normalization-core/number-coercion"; import { asNullableRecord } from "@openclaw/normalization-core/record-coerce"; import { styleHealthChannelLine } from "../../packages/terminal-core/src/health-style.js"; import { isRich } from "../../packages/terminal-core/src/theme.js"; @@ -428,7 +429,7 @@ export async function getHealthSnapshot(params?: { (await buildSessionSummary(resolveStorePath(cfg.session?.store, { agentId: defaultAgentId }))); const start = Date.now(); - const cappedTimeout = timeoutMs === undefined ? DEFAULT_TIMEOUT_MS : Math.max(50, timeoutMs); + const cappedTimeout = resolveTimerTimeoutMs(timeoutMs, DEFAULT_TIMEOUT_MS, 50); const doProbe = params?.probe !== false; const includeSensitive = params?.includeSensitive !== false; const channels: Record = {};