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

推荐订阅源

博客园 - 叶小钗
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Microsoft Security Blog
Microsoft Security Blog
罗磊的独立博客
大猫的无限游戏
大猫的无限游戏
美团技术团队
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
aimingoo的专栏
aimingoo的专栏
腾讯CDC
WordPress大学
WordPress大学
Apple Machine Learning Research
Apple Machine Learning Research
F
Fortinet All Blogs
G
Google Developers Blog
MongoDB | Blog
MongoDB | Blog
Microsoft Azure Blog
Microsoft Azure Blog
小众软件
小众软件
Engineering at Meta
Engineering at Meta
博客园_首页
B
Blog RSS Feed
D
Docker
M
MIT News - Artificial intelligence
爱范儿
爱范儿
I
InfoQ

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 MCP channel limits · openclaw/open...
vincentkoc · 2026-05-30 · via Recent Commits to openclaw:main
Original file line numberDiff line numberDiff line change

@@ -0,0 +1,23 @@

1+

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

2+
3+

export type McpChannelLimits = {

4+

connectTimeoutMs: number;

5+

gatewayEventRetainLimit: number;

6+

rawMessageRetainLimit: number;

7+

};

8+
9+

export function readMcpChannelLimits(env: NodeJS.ProcessEnv = process.env): McpChannelLimits {

10+

return {

11+

connectTimeoutMs: readPositiveIntEnv("OPENCLAW_MCP_CHANNELS_CONNECT_TIMEOUT_MS", 60_000, env),

12+

gatewayEventRetainLimit: readPositiveIntEnv(

13+

"OPENCLAW_MCP_CHANNELS_GATEWAY_EVENT_RETAIN_LIMIT",

14+

2_000,

15+

env,

16+

),

17+

rawMessageRetainLimit: readPositiveIntEnv(

18+

"OPENCLAW_MCP_CHANNELS_RAW_MESSAGE_RETAIN_LIMIT",

19+

2_000,

20+

env,

21+

),

22+

};

23+

}

Original file line numberDiff line numberDiff line change

@@ -13,6 +13,7 @@ import { PROTOCOL_VERSION } from "../../dist/gateway/protocol/index.js";

1313

import { formatErrorMessage } from "../../dist/infra/errors.js";

1414

import { rawDataToString } from "../../dist/infra/ws.js";

1515

import { readStringValue } from "../../dist/shared/string-coerce.js";

16+

import { readMcpChannelLimits } from "./mcp-channel-limits.ts";

1617

import { connectMcpWithTimeout } from "./mcp-connect-timeout.ts";

1718

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

1819

@@ -50,30 +51,17 @@ const GATEWAY_WS_OPEN_TIMEOUT_MS = 45_000;

5051

const GATEWAY_RPC_TIMEOUT_MS = 60_000;

5152

const GATEWAY_REQUEST_TIMEOUT_MS = 45_000;

5253

const GATEWAY_CONNECT_RETRY_WINDOW_MS = 420_000;

53-

const MCP_CONNECT_TIMEOUT_MS = readPositiveInt(

54-

process.env.OPENCLAW_MCP_CHANNELS_CONNECT_TIMEOUT_MS,

55-

60_000,

56-

);

57-

const GATEWAY_EVENT_RETAIN_LIMIT = readPositiveInt(

58-

process.env.OPENCLAW_MCP_CHANNELS_GATEWAY_EVENT_RETAIN_LIMIT,

59-

2_000,

60-

);

61-

const MCP_RAW_MESSAGE_RETAIN_LIMIT = readPositiveInt(

62-

process.env.OPENCLAW_MCP_CHANNELS_RAW_MESSAGE_RETAIN_LIMIT,

63-

2_000,

64-

);

54+

const MCP_CHANNEL_LIMITS = readMcpChannelLimits();

55+

const MCP_CONNECT_TIMEOUT_MS = MCP_CHANNEL_LIMITS.connectTimeoutMs;

56+

const GATEWAY_EVENT_RETAIN_LIMIT = MCP_CHANNEL_LIMITS.gatewayEventRetainLimit;

57+

const MCP_RAW_MESSAGE_RETAIN_LIMIT = MCP_CHANNEL_LIMITS.rawMessageRetainLimit;

6558
6659

export function assert(condition: unknown, message: string): asserts condition {

6760

if (!condition) {

6861

throw new Error(message);

6962

}

7063

}

7164
72-

function readPositiveInt(raw: string | undefined, fallback: number) {

73-

const parsed = Number.parseInt(raw ?? "", 10);

74-

return Number.isInteger(parsed) && parsed > 0 ? parsed : fallback;

75-

}

76-
7765

function pushBounded<T>(items: T[], item: T, limit: number): void {

7866

items.push(item);

7967

if (items.length > limit) {

Original file line numberDiff line numberDiff line change

@@ -0,0 +1,39 @@

1+

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

2+

import { readMcpChannelLimits } from "../../scripts/e2e/mcp-channel-limits.ts";

3+
4+

describe("MCP channel E2E limits", () => {

5+

it("uses documented defaults when env overrides are absent", () => {

6+

expect(readMcpChannelLimits({})).toEqual({

7+

connectTimeoutMs: 60_000,

8+

gatewayEventRetainLimit: 2_000,

9+

rawMessageRetainLimit: 2_000,

10+

});

11+

});

12+
13+

it("accepts strict positive integer overrides", () => {

14+

expect(

15+

readMcpChannelLimits({

16+

OPENCLAW_MCP_CHANNELS_CONNECT_TIMEOUT_MS: "120000",

17+

OPENCLAW_MCP_CHANNELS_GATEWAY_EVENT_RETAIN_LIMIT: "500",

18+

OPENCLAW_MCP_CHANNELS_RAW_MESSAGE_RETAIN_LIMIT: "25",

19+

}),

20+

).toEqual({

21+

connectTimeoutMs: 120_000,

22+

gatewayEventRetainLimit: 500,

23+

rawMessageRetainLimit: 25,

24+

});

25+

});

26+
27+

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

28+

expect(() =>

29+

readMcpChannelLimits({

30+

OPENCLAW_MCP_CHANNELS_CONNECT_TIMEOUT_MS: "1e3",

31+

}),

32+

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

33+

expect(() =>

34+

readMcpChannelLimits({

35+

OPENCLAW_MCP_CHANNELS_RAW_MESSAGE_RETAIN_LIMIT: "1000ms",

36+

}),

37+

).toThrow("invalid OPENCLAW_MCP_CHANNELS_RAW_MESSAGE_RETAIN_LIMIT: 1000ms");

38+

});

39+

});