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

推荐订阅源

GbyAI
GbyAI
Y
Y Combinator Blog
F
Fortinet All Blogs
H
Hackread – Cybersecurity News, Data Breaches, AI and More
N
Netflix TechBlog - Medium
T
Tailwind CSS Blog
aimingoo的专栏
aimingoo的专栏
博客园 - Franky
T
The Blog of Author Tim Ferriss
D
DataBreaches.Net
量子位
博客园 - 三生石上(FineUI控件)
I
InfoQ
Engineering at Meta
Engineering at Meta
WordPress大学
WordPress大学
阮一峰的网络日志
阮一峰的网络日志
爱范儿
爱范儿
D
Docker
美团技术团队
雷峰网
雷峰网
U
Unit 42
Stack Overflow Blog
Stack Overflow Blog
Recent Announcements
Recent Announcements
人人都是产品经理
人人都是产品经理

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 tool search fetch limits · opencla...
vincentkoc · 2026-05-30 · via Recent Commits to openclaw:main
Original file line numberDiff line numberDiff line change

@@ -10,6 +10,7 @@ import { stageQaMockAuthProfiles } from "../extensions/qa-lab/src/providers/shar

1010

import { buildQaGatewayConfig } from "../extensions/qa-lab/src/qa-gateway-config.js";

1111

import { resetConfigRuntimeState } from "../src/config/config.js";

1212

import { startGatewayServer } from "../src/gateway/server.js";

13+

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

1314

import { readBoundedResponseText } from "./lib/bounded-response.ts";

1415
1516

type Lane = "normal" | "code";

@@ -34,26 +35,36 @@ type LaneResult = {

3435

};

3536
3637

const FAKE_PLUGIN_ID = "tool-search-e2e-fixture";

37-

const DEFAULT_FETCH_TIMEOUT_MS = readPositiveInt(

38-

process.env.OPENCLAW_TOOL_SEARCH_GATEWAY_E2E_FETCH_TIMEOUT_MS,

39-

180_000,

40-

);

41-

const DEFAULT_FETCH_BODY_MAX_BYTES = readPositiveInt(

42-

process.env.OPENCLAW_TOOL_SEARCH_GATEWAY_E2E_FETCH_BODY_MAX_BYTES,

43-

1024 * 1024,

44-

);

38+

export type ToolSearchGatewayFetchLimits = {

39+

bodyMaxBytes: number;

40+

timeoutMs: number;

41+

};

4542
4643

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

4744

if (!condition) {

4845

throw new Error(message);

4946

}

5047

}

5148
52-

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

53-

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

54-

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

49+

export function readToolSearchGatewayFetchLimits(

50+

env: NodeJS.ProcessEnv = process.env,

51+

): ToolSearchGatewayFetchLimits {

52+

return {

53+

bodyMaxBytes: readPositiveIntEnv(

54+

"OPENCLAW_TOOL_SEARCH_GATEWAY_E2E_FETCH_BODY_MAX_BYTES",

55+

1024 * 1024,

56+

env,

57+

),

58+

timeoutMs: readPositiveIntEnv(

59+

"OPENCLAW_TOOL_SEARCH_GATEWAY_E2E_FETCH_TIMEOUT_MS",

60+

180_000,

61+

env,

62+

),

63+

};

5564

}

5665
66+

const DEFAULT_FETCH_LIMITS = readToolSearchGatewayFetchLimits();

67+
5768

function timeoutError(message: string) {

5869

return Object.assign(new Error(message), { code: "ETIMEDOUT" });

5970

}

@@ -145,8 +156,8 @@ export async function fetchJson(

145156

init: RequestInit = {},

146157

options: FetchJsonOptions = {},

147158

): Promise<unknown> {

148-

const timeoutMs = Math.max(1, options.timeoutMs ?? DEFAULT_FETCH_TIMEOUT_MS);

149-

const maxBodyBytes = Math.max(1, options.maxBodyBytes ?? DEFAULT_FETCH_BODY_MAX_BYTES);

159+

const timeoutMs = Math.max(1, options.timeoutMs ?? DEFAULT_FETCH_LIMITS.timeoutMs);

160+

const maxBodyBytes = Math.max(1, options.maxBodyBytes ?? DEFAULT_FETCH_LIMITS.bodyMaxBytes);

150161

const controller = new AbortController();

151162

const error = timeoutError(`HTTP request to ${url} timed out after ${timeoutMs}ms`);

152163

let timeout: ReturnType<typeof setNodeTimeout> | undefined;

Original file line numberDiff line numberDiff line change

@@ -1,7 +1,32 @@

11

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

2-

import { fetchJson } from "../../scripts/tool-search-gateway-e2e.ts";

2+

import {

3+

fetchJson,

4+

readToolSearchGatewayFetchLimits,

5+

} from "../../scripts/tool-search-gateway-e2e.ts";

36
47

describe("tool search gateway e2e fetch helper", () => {

8+

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

9+

expect(() =>

10+

readToolSearchGatewayFetchLimits({

11+

OPENCLAW_TOOL_SEARCH_GATEWAY_E2E_FETCH_TIMEOUT_MS: "1e3",

12+

}),

13+

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

14+

expect(() =>

15+

readToolSearchGatewayFetchLimits({

16+

OPENCLAW_TOOL_SEARCH_GATEWAY_E2E_FETCH_BODY_MAX_BYTES: "1000ms",

17+

}),

18+

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

19+

expect(

20+

readToolSearchGatewayFetchLimits({

21+

OPENCLAW_TOOL_SEARCH_GATEWAY_E2E_FETCH_BODY_MAX_BYTES: "4096",

22+

OPENCLAW_TOOL_SEARCH_GATEWAY_E2E_FETCH_TIMEOUT_MS: "120000",

23+

}),

24+

).toEqual({

25+

bodyMaxBytes: 4096,

26+

timeoutMs: 120_000,

27+

});

28+

});

29+
530

it("aborts requests that never resolve", async () => {

631

let signal: AbortSignal | undefined;

732

await expect(