fix(tui): clamp local shutdown grace timeout · openclaw/openclaw@c21dcfc
vincentkoc
·
2026-06-22
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
|
1 | 1 | // Coordinates graceful shutdown for local TUI runs. |
2 | | -import { parseStrictNonNegativeInteger } from "../infra/parse-finite-number.js"; |
| 2 | +import { |
| 3 | +MAX_TIMER_TIMEOUT_MS, |
| 4 | +parseStrictNonNegativeInteger, |
| 5 | +} from "../infra/parse-finite-number.js"; |
3 | 6 | |
4 | 7 | // Local TUI runs get extra shutdown time because embedded agents/providers may still be closing. |
5 | 8 | const LOCAL_RUN_SHUTDOWN_GRACE_MS = 120_000; |
@@ -9,7 +12,7 @@ export function resolveLocalRunShutdownGraceMs(): number {
|
9 | 12 | const raw = process.env.OPENCLAW_TUI_LOCAL_RUN_SHUTDOWN_GRACE_MS?.trim(); |
10 | 13 | const parsed = parseStrictNonNegativeInteger(raw); |
11 | 14 | if (parsed !== undefined) { |
12 | | -return parsed; |
| 15 | +return Math.min(parsed, MAX_TIMER_TIMEOUT_MS); |
13 | 16 | } |
14 | 17 | return LOCAL_RUN_SHUTDOWN_GRACE_MS; |
15 | 18 | } |
| Original file line number | Diff line number | Diff line change |
|---|
@@ -2,6 +2,7 @@
|
2 | 2 | import { EventEmitter } from "node:events"; |
3 | 3 | import { describe, expect, it, vi } from "vitest"; |
4 | 4 | import type { OpenClawConfig } from "../config/config.js"; |
| 5 | +import { MAX_TIMER_TIMEOUT_MS } from "../infra/parse-finite-number.js"; |
5 | 6 | import { MALFORMED_STREAMING_FRAGMENT_ERROR_MESSAGE } from "../shared/assistant-error-format.js"; |
6 | 7 | import { withEnv } from "../test-utils/env.js"; |
7 | 8 | import { getSlashCommands, parseCommand } from "./commands.js"; |
@@ -237,6 +238,14 @@ describe("resolveTuiShutdownHardExitMs", () => {
|
237 | 238 | expect(resolveTuiShutdownHardExitMs({ localMode: true })).toBe(122000); |
238 | 239 | }); |
239 | 240 | }); |
| 241 | + |
| 242 | +it("clamps oversized local run shutdown grace values", () => { |
| 243 | +withEnv({ OPENCLAW_TUI_LOCAL_RUN_SHUTDOWN_GRACE_MS: String(Number.MAX_SAFE_INTEGER) }, () => { |
| 244 | +expect(resolveTuiShutdownHardExitMs({ localMode: true })).toBe( |
| 245 | +MAX_TIMER_TIMEOUT_MS + 2000, |
| 246 | +); |
| 247 | +}); |
| 248 | +}); |
240 | 249 | }); |
241 | 250 | |
242 | 251 | describe("resolveTuiSessionKey", () => { |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。