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

推荐订阅源

人人都是产品经理
人人都是产品经理
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
宝玉的分享
宝玉的分享
月光博客
月光博客
爱范儿
爱范儿
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
WordPress大学
WordPress大学
有赞技术团队
有赞技术团队
阮一峰的网络日志
阮一峰的网络日志
博客园_首页
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - 三生石上(FineUI控件)
博客园 - 聂微东
小众软件
小众软件
量子位
MongoDB | Blog
MongoDB | Blog
Blog — PlanetScale
Blog — PlanetScale
The Cloudflare Blog
Stack Overflow Blog
Stack Overflow Blog
U
Unit 42
Hugging Face - Blog
Hugging Face - Blog
T
The Blog of Author Tim Ferriss
H
Help Net Security
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC

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(gateway): cap handshake timer delays · openclaw/openc...
steipete · 2026-05-29 · via Recent Commits to openclaw:main
Original file line numberDiff line numberDiff line change

@@ -1,7 +1,11 @@

11

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

22

import {

3+

getConnectChallengeTimeoutMsFromEnv,

4+

getPreauthHandshakeTimeoutMsFromEnv,

35

MAX_SAFE_TIMEOUT_DELAY_MS,

46

resolveFiniteTimeoutDelayMs,

7+

resolveConnectChallengeTimeoutMs,

8+

resolvePreauthHandshakeTimeoutMs,

59

resolveSafeTimeoutDelayMs,

610

} from "./timeouts.js";

711

@@ -35,3 +39,38 @@ describe("resolveFiniteTimeoutDelayMs", () => {

3539

expect(resolveFiniteTimeoutDelayMs(-5, 10_000, { minMs: 0 })).toBe(0);

3640

});

3741

});

42+
43+

describe("gateway client handshake timeouts", () => {

44+

it("caps preauth handshake timeout env and config values to the safe timer range", () => {

45+

expect(

46+

getPreauthHandshakeTimeoutMsFromEnv({

47+

OPENCLAW_HANDSHAKE_TIMEOUT_MS: "3000000000",

48+

}),

49+

).toBe(MAX_SAFE_TIMEOUT_DELAY_MS);

50+

expect(

51+

resolvePreauthHandshakeTimeoutMs({

52+

env: {},

53+

configuredTimeoutMs: 3_000_000_000,

54+

}),

55+

).toBe(MAX_SAFE_TIMEOUT_DELAY_MS);

56+

});

57+
58+

it("caps connect challenge timeout env and explicit values to the safe timer range", () => {

59+

expect(

60+

getConnectChallengeTimeoutMsFromEnv({

61+

OPENCLAW_CONNECT_CHALLENGE_TIMEOUT_MS: "3000000000",

62+

}),

63+

).toBe(MAX_SAFE_TIMEOUT_DELAY_MS);

64+

expect(

65+

resolveConnectChallengeTimeoutMs(3_000_000_000, {

66+

env: {},

67+

configuredTimeoutMs: 3_000_000_000,

68+

}),

69+

).toBe(MAX_SAFE_TIMEOUT_DELAY_MS);

70+

expect(

71+

resolveConnectChallengeTimeoutMs(undefined, {

72+

env: { OPENCLAW_CONNECT_CHALLENGE_TIMEOUT_MS: "3000000000" },

73+

}),

74+

).toBe(MAX_SAFE_TIMEOUT_DELAY_MS);

75+

});

76+

});

Original file line numberDiff line numberDiff line change

@@ -48,15 +48,15 @@ export function getConnectChallengeTimeoutMsFromEnv(

4848

if (raw) {

4949

const parsed = parseStrictPositiveInteger(raw);

5050

if (parsed !== undefined) {

51-

return parsed;

51+

return resolveSafeTimeoutDelayMs(parsed);

5252

}

5353

}

5454

return undefined;

5555

}

5656
5757

function normalizePositiveTimeoutMs(timeoutMs: unknown): number | undefined {

5858

return typeof timeoutMs === "number" && Number.isFinite(timeoutMs) && timeoutMs > 0

59-

? timeoutMs

59+

? resolveSafeTimeoutDelayMs(timeoutMs)

6060

: undefined;

6161

}

6262

@@ -90,7 +90,7 @@ export function getPreauthHandshakeTimeoutMsFromEnv(env: NodeJS.ProcessEnv = pro

9090

if (configuredTimeout) {

9191

const parsed = parseStrictPositiveInteger(configuredTimeout);

9292

if (parsed !== undefined) {

93-

return parsed;

93+

return resolveSafeTimeoutDelayMs(parsed);

9494

}

9595

}

9696

return DEFAULT_PREAUTH_HANDSHAKE_TIMEOUT_MS;

@@ -106,7 +106,7 @@ export function resolvePreauthHandshakeTimeoutMs(params?: {

106106

if (configuredTimeout) {

107107

const parsed = parseStrictPositiveInteger(configuredTimeout);

108108

if (parsed !== undefined) {

109-

return parsed;

109+

return resolveSafeTimeoutDelayMs(parsed);

110110

}

111111

}

112112

const configured = normalizePositiveTimeoutMs(params?.configuredTimeoutMs);

Original file line numberDiff line numberDiff line change

@@ -1,4 +1,5 @@

11

import { describe, expect, test } from "vitest";

2+

import { MAX_SAFE_TIMEOUT_DELAY_MS } from "../utils/timer-delay.js";

23

import {

34

clampConnectChallengeTimeoutMs,

45

DEFAULT_PREAUTH_HANDSHAKE_TIMEOUT_MS,

@@ -62,6 +63,20 @@ describe("gateway handshake timeouts", () => {

6263

);

6364

});

6465
66+

test("caps preauth handshake timeout env and config values to the safe timer range", () => {

67+

expect(

68+

getPreauthHandshakeTimeoutMsFromEnv({

69+

OPENCLAW_HANDSHAKE_TIMEOUT_MS: "3000000000",

70+

}),

71+

).toBe(MAX_SAFE_TIMEOUT_DELAY_MS);

72+

expect(

73+

resolvePreauthHandshakeTimeoutMs({

74+

env: {},

75+

configuredTimeoutMs: 3_000_000_000,

76+

}),

77+

).toBe(MAX_SAFE_TIMEOUT_DELAY_MS);

78+

});

79+
6580

test("resolves preauth handshake timeout from the test-only env before config", () => {

6681

expect(

6782

resolvePreauthHandshakeTimeoutMs({

@@ -122,6 +137,25 @@ describe("gateway handshake timeouts", () => {

122137

).toBeUndefined();

123138

});

124139
140+

test("caps connect challenge timeout env and explicit values to the safe timer range", () => {

141+

expect(

142+

getConnectChallengeTimeoutMsFromEnv({

143+

OPENCLAW_CONNECT_CHALLENGE_TIMEOUT_MS: "3000000000",

144+

}),

145+

).toBe(MAX_SAFE_TIMEOUT_DELAY_MS);

146+

expect(

147+

resolveConnectChallengeTimeoutMs(3_000_000_000, {

148+

env: {},

149+

configuredTimeoutMs: 3_000_000_000,

150+

}),

151+

).toBe(MAX_SAFE_TIMEOUT_DELAY_MS);

152+

expect(

153+

resolveConnectChallengeTimeoutMs(undefined, {

154+

env: { OPENCLAW_CONNECT_CHALLENGE_TIMEOUT_MS: "3000000000" },

155+

}),

156+

).toBe(MAX_SAFE_TIMEOUT_DELAY_MS);

157+

});

158+
125159

test("resolveConnectChallengeTimeoutMs falls back to env override", () => {

126160

const original = process.env.OPENCLAW_CONNECT_CHALLENGE_TIMEOUT_MS;

127161

const originalHandshake = process.env.OPENCLAW_HANDSHAKE_TIMEOUT_MS;

Original file line numberDiff line numberDiff line change

@@ -1,4 +1,5 @@

11

import { parseStrictPositiveInteger } from "../infra/parse-finite-number.js";

2+

import { resolveSafeTimeoutDelayMs } from "../utils/timer-delay.js";

23
34

export const DEFAULT_PREAUTH_HANDSHAKE_TIMEOUT_MS = 15_000;

45

export const MIN_CONNECT_CHALLENGE_TIMEOUT_MS = 250;

@@ -21,15 +22,15 @@ export function getConnectChallengeTimeoutMsFromEnv(

2122

if (raw) {

2223

const parsed = parseStrictPositiveInteger(raw);

2324

if (parsed !== undefined) {

24-

return parsed;

25+

return resolveSafeTimeoutDelayMs(parsed);

2526

}

2627

}

2728

return undefined;

2829

}

2930
3031

function normalizePositiveTimeoutMs(timeoutMs: unknown): number | undefined {

3132

return typeof timeoutMs === "number" && Number.isFinite(timeoutMs) && timeoutMs > 0

32-

? timeoutMs

33+

? resolveSafeTimeoutDelayMs(timeoutMs)

3334

: undefined;

3435

}

3536

@@ -61,7 +62,7 @@ export function getPreauthHandshakeTimeoutMsFromEnv(env: NodeJS.ProcessEnv = pro

6162

if (configuredTimeout) {

6263

const parsed = parseStrictPositiveInteger(configuredTimeout);

6364

if (parsed !== undefined) {

64-

return parsed;

65+

return resolveSafeTimeoutDelayMs(parsed);

6566

}

6667

}

6768

return DEFAULT_PREAUTH_HANDSHAKE_TIMEOUT_MS;

@@ -77,7 +78,7 @@ export function resolvePreauthHandshakeTimeoutMs(params?: {

7778

if (configuredTimeout) {

7879

const parsed = parseStrictPositiveInteger(configuredTimeout);

7980

if (parsed !== undefined) {

80-

return parsed;

81+

return resolveSafeTimeoutDelayMs(parsed);

8182

}

8283

}

8384

const configured = normalizePositiveTimeoutMs(params?.configuredTimeoutMs);