惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

The GitHub Blog
The GitHub Blog
博客园 - 三生石上(FineUI控件)
V
V2EX
博客园 - 司徒正美
小众软件
小众软件
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
T
Tailwind CSS Blog
Last Week in AI
Last Week in AI
雷峰网
雷峰网
月光博客
月光博客
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Apple Machine Learning Research
Apple Machine Learning Research
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
S
SegmentFault 最新的问题
美团技术团队
Hugging Face - Blog
Hugging Face - Blog
WordPress大学
WordPress大学
宝玉的分享
宝玉的分享
爱范儿
爱范儿
博客园 - 聂微东
量子位
J
Java Code Geeks
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Vercel News
Vercel News

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
fix(scripts): clamp telegram proof timeouts · openclaw/op...
vincentkoc · 2026-06-22 · via Recent Commits to openclaw:main
Original file line numberDiff line numberDiff line change

@@ -11,6 +11,7 @@ import fs from "node:fs";

1111

import os from "node:os";

1212

import path from "node:path";

1313

import { fileURLToPath } from "node:url";

14+

import { clampTimerTimeoutMs } from "@openclaw/normalization-core/number-coercion";

1415

import { resolveWindowsTaskkillPath } from "../lib/windows-taskkill.mjs";

1516

import { createPnpmRunnerSpawnSpec } from "../pnpm-runner.mjs";

1617

import { readPositiveIntEnv } from "./lib/env-limits.mjs";

@@ -253,6 +254,14 @@ function parsePositiveInteger(value: string, label: string) {

253254

return parsed;

254255

}

255256
257+

function resolveTelegramProofTimerTimeoutMs(value: number) {

258+

return clampTimerTimeoutMs(value) ?? 1;

259+

}

260+
261+

function parsePositiveTimerMs(value: string, label: string) {

262+

return resolveTelegramProofTimerTimeoutMs(parsePositiveInteger(value, label));

263+

}

264+
256265

function parseTcpPort(value: string, label: string) {

257266

const parsed = parsePositiveInteger(value, label);

258267

if (parsed > 65_535) {

@@ -394,7 +403,7 @@ export function parseArgs(argvInput: string[]): Options {

394403

} else if (arg === "--text") {

395404

opts.text = readValue();

396405

} else if (arg === "--timeout-ms") {

397-

opts.timeoutMs = parsePositiveInteger(readValue(), "--timeout-ms");

406+

opts.timeoutMs = parsePositiveTimerMs(readValue(), "--timeout-ms");

398407

} else if (arg === "--ttl") {

399408

opts.ttl = readValue();

400409

} else if (arg === "--user-driver-script") {

@@ -747,8 +756,10 @@ export function runCommand(params: {

747756

let timeoutError: Error | null = null;

748757

let forceKillAt: number | undefined;

749758

let killTimer: NodeJS.Timeout | undefined;

750-

const timeoutMs = params.timeoutMs ?? COMMAND_TIMEOUT_MS;

751-

const timeoutKillGraceMs = params.timeoutKillGraceMs ?? COMMAND_TIMEOUT_KILL_GRACE_MS;

759+

const timeoutMs = resolveTelegramProofTimerTimeoutMs(params.timeoutMs ?? COMMAND_TIMEOUT_MS);

760+

const timeoutKillGraceMs = resolveTelegramProofTimerTimeoutMs(

761+

params.timeoutKillGraceMs ?? COMMAND_TIMEOUT_KILL_GRACE_MS,

762+

);

752763

const clearTimers = () => {

753764

clearTimeout(timeout);

754765

if (killTimer) {

@@ -888,11 +899,14 @@ function waitForOutput(

888899

timeoutMs: number,

889900

) {

890901

return new Promise<void>((resolve, reject) => {

902+

const resolvedTimeoutMs = resolveTelegramProofTimerTimeoutMs(timeoutMs);

891903

const timeout = setTimeout(() => {

892904

reject(

893-

new Error(`${label} did not become ready within ${timeoutMs}ms\n${output().slice(-4000)}`),

905+

new Error(

906+

`${label} did not become ready within ${resolvedTimeoutMs}ms\n${output().slice(-4000)}`,

907+

),

894908

);

895-

}, timeoutMs);

909+

}, resolvedTimeoutMs);

896910

const onData = () => {

897911

if (pattern.test(output())) {

898912

cleanup();

Original file line numberDiff line numberDiff line change

@@ -5,6 +5,7 @@ import os from "node:os";

55

import path from "node:path";

66

import { setTimeout as delay } from "node:timers/promises";

77

import { pathToFileURL } from "node:url";

8+

import { MAX_TIMER_TIMEOUT_MS } from "@openclaw/normalization-core/number-coercion";

89

import { afterEach, describe, expect, it, vi } from "vitest";

910

import {

1011

COMMAND_TIMEOUT_MS,

@@ -156,6 +157,12 @@ describe("telegram user Crabbox proof log polling", () => {

156157

expect(parseArgs(["--text", "-ping"]).text).toBe("-ping");

157158

});

158159
160+

it("clamps proof timeout args before they reach Node timers", () => {

161+

expect(parseArgs(["--timeout-ms", String(MAX_TIMER_TIMEOUT_MS + 1)]).timeoutMs).toBe(

162+

MAX_TIMER_TIMEOUT_MS,

163+

);

164+

});

165+
159166

it("reads only the requested log tail", () => {

160167

const logPath = path.join(makeTempDir(), "gateway.log");

161168

fs.writeFileSync(logPath, `${"old\n".repeat(2000)}ready\n`, "utf8");

@@ -309,6 +316,22 @@ fs.writeFileSync(process.env.OPENCLAW_TEST_ARGV_PATH, JSON.stringify(process.arg

309316

expect(JSON.parse(fs.readFileSync(argvPath, "utf8"))).toContain(payload);

310317

});

311318
319+

it("clamps oversized command timeouts before arming timers", async () => {

320+

const setTimeoutSpy = vi.spyOn(globalThis, "setTimeout");

321+
322+

await expect(

323+

runCommand({

324+

args: ["--version"],

325+

command: process.execPath,

326+

cwd: process.cwd(),

327+

timeoutMs: MAX_TIMER_TIMEOUT_MS + 1,

328+

}),

329+

).resolves.toMatchObject({ stderr: "" });

330+
331+

expect(setTimeoutSpy).toHaveBeenCalledWith(expect.any(Function), MAX_TIMER_TIMEOUT_MS);

332+

setTimeoutSpy.mockRestore();

333+

});

334+
312335

posixIt("kills timed-out command process groups when the leader exits first", async () => {

313336

const root = makeTempDir();

314337

const scriptPath = path.join(root, "trap-term.mjs");