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

推荐订阅源

S
SegmentFault 最新的问题
G
Google Developers Blog
Stack Overflow Blog
Stack Overflow Blog
WordPress大学
WordPress大学
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
罗磊的独立博客
月光博客
月光博客
IT之家
IT之家
爱范儿
爱范儿
Google DeepMind News
Google DeepMind News
小众软件
小众软件
C
Check Point Blog
B
Blog RSS Feed
H
Help Net Security
博客园 - 司徒正美
L
LangChain Blog
MongoDB | Blog
MongoDB | Blog
B
Blog
The Cloudflare Blog
Apple Machine Learning Research
Apple Machine Learning Research
Microsoft Security Blog
Microsoft Security Blog
M
MIT News - Artificial intelligence
N
Netflix TechBlog - Medium
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知

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(e2e): reject loose gateway network timeouts · opencla...
vincentkoc · 2026-05-29 · via Recent Commits to openclaw:main

File tree

  • scripts/e2e/lib/gateway-network

Original file line numberDiff line numberDiff line change

@@ -1,5 +1,6 @@

11

import { WebSocket } from "ws";

22

import { PROTOCOL_VERSION } from "../../../../dist/gateway/protocol/index.js";

3+

import { readGatewayNetworkClientConnectTimeoutMs } from "./limits.mjs";

34

import { waitForWebSocketOpen } from "./open-websocket.mjs";

45
56

const url = process.env.GW_URL;

@@ -8,16 +9,7 @@ if (!url || !token) {

89

throw new Error("missing GW_URL/GW_TOKEN");

910

}

1011
11-

const deadlineMs = Number.parseInt(

12-

process.env.OPENCLAW_GATEWAY_NETWORK_CLIENT_CONNECT_TIMEOUT_MS ??

13-

process.env.OPENCLAW_GATEWAY_NETWORK_CONNECT_READY_TIMEOUT_MS ??

14-

"80000",

15-

10,

16-

);

17-

if (!Number.isFinite(deadlineMs) || deadlineMs < 0) {

18-

throw new Error(`invalid gateway network client timeout: ${String(deadlineMs)}`);

19-

}

20-

const deadline = Date.now() + Math.max(1_000, deadlineMs);

12+

const deadline = Date.now() + readGatewayNetworkClientConnectTimeoutMs();

2113
2214

function delay(ms) {

2315

return new Promise((resolve) => setTimeout(resolve, ms));

Original file line numberDiff line numberDiff line change

@@ -0,0 +1,18 @@

1+

function readPositiveIntEnv(name, fallback, env) {

2+

const text = String(env[name] ?? fallback).trim();

3+

if (!/^\d+$/u.test(text)) {

4+

throw new Error(`invalid ${name}: ${text}`);

5+

}

6+

const value = Number(text);

7+

if (!Number.isSafeInteger(value) || value <= 0) {

8+

throw new Error(`invalid ${name}: ${text}`);

9+

}

10+

return value;

11+

}

12+
13+

export function readGatewayNetworkClientConnectTimeoutMs(env = process.env) {

14+

if (env.OPENCLAW_GATEWAY_NETWORK_CLIENT_CONNECT_TIMEOUT_MS != null) {

15+

return readPositiveIntEnv("OPENCLAW_GATEWAY_NETWORK_CLIENT_CONNECT_TIMEOUT_MS", 80000, env);

16+

}

17+

return readPositiveIntEnv("OPENCLAW_GATEWAY_NETWORK_CONNECT_READY_TIMEOUT_MS", 80000, env);

18+

}

Original file line numberDiff line numberDiff line change

@@ -1,5 +1,6 @@

11

import { EventEmitter } from "node:events";

22

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

3+

import { readGatewayNetworkClientConnectTimeoutMs } from "../../scripts/e2e/lib/gateway-network/limits.mjs";

34

import { waitForWebSocketOpen } from "../../scripts/e2e/lib/gateway-network/open-websocket.mjs";

45
56

class FakeWebSocket extends EventEmitter {

@@ -20,6 +21,38 @@ class FakeWebSocket extends EventEmitter {

2021

}

2122
2223

describe("gateway network WebSocket open guard", () => {

24+

it("rejects loose client timeout env values instead of parsing prefixes", () => {

25+

expect(() =>

26+

readGatewayNetworkClientConnectTimeoutMs({

27+

OPENCLAW_GATEWAY_NETWORK_CLIENT_CONNECT_TIMEOUT_MS: "100ms",

28+

}),

29+

).toThrow("invalid OPENCLAW_GATEWAY_NETWORK_CLIENT_CONNECT_TIMEOUT_MS: 100ms");

30+

expect(() =>

31+

readGatewayNetworkClientConnectTimeoutMs({

32+

OPENCLAW_GATEWAY_NETWORK_CONNECT_READY_TIMEOUT_MS: "1e3",

33+

}),

34+

).toThrow("invalid OPENCLAW_GATEWAY_NETWORK_CONNECT_READY_TIMEOUT_MS: 1e3");

35+

expect(() =>

36+

readGatewayNetworkClientConnectTimeoutMs({

37+

OPENCLAW_GATEWAY_NETWORK_CLIENT_CONNECT_TIMEOUT_MS: "0",

38+

}),

39+

).toThrow("invalid OPENCLAW_GATEWAY_NETWORK_CLIENT_CONNECT_TIMEOUT_MS: 0");

40+

});

41+
42+

it("prefers the explicit client timeout over the connect-ready fallback", () => {

43+

expect(

44+

readGatewayNetworkClientConnectTimeoutMs({

45+

OPENCLAW_GATEWAY_NETWORK_CLIENT_CONNECT_TIMEOUT_MS: "5000",

46+

OPENCLAW_GATEWAY_NETWORK_CONNECT_READY_TIMEOUT_MS: "1000",

47+

}),

48+

).toBe(5000);

49+

expect(

50+

readGatewayNetworkClientConnectTimeoutMs({

51+

OPENCLAW_GATEWAY_NETWORK_CONNECT_READY_TIMEOUT_MS: "3000",

52+

}),

53+

).toBe(3000);

54+

});

55+
2356

it("consumes abort errors after open timeouts", async () => {

2457

const ws = new FakeWebSocket();

2558

const keepAlive = setTimeout(() => {}, 100);