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

推荐订阅源

小众软件
小众软件
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
WordPress大学
WordPress大学
月光博客
月光博客
Hugging Face - Blog
Hugging Face - Blog
博客园 - 聂微东
博客园 - 【当耐特】
博客园_首页
The Cloudflare Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Apple Machine Learning Research
Apple Machine Learning Research
Last Week in AI
Last Week in AI
酷 壳 – CoolShell
酷 壳 – CoolShell
大猫的无限游戏
大猫的无限游戏
雷峰网
雷峰网
量子位
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
T
Tailwind CSS Blog
IT之家
IT之家
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
GbyAI
GbyAI
V
Visual Studio Blog
F
Fortinet All Blogs
Martin Fowler
Martin Fowler

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): cap memory FD repro RPC bodies · openclaw/o...
vincentkoc · 2026-05-29 · via Recent Commits to openclaw:main
Original file line numberDiff line numberDiff line change

@@ -25,6 +25,7 @@ const ISSUE_MEMORY_FILE_COUNT = ISSUE_FILE_COUNTS.reduce((sum, [, count]) => sum

2525

const DEFAULT_FILE_COUNT = 512;

2626

const DEFAULT_MAX_WORKSPACE_REG_FDS = process.platform === "darwin" ? 8 : 64;

2727

export const GATEWAY_READY_OUTPUT_MAX_CHARS = 128 * 1024;

28+

export const MEMORY_SEARCH_RESPONSE_MAX_BYTES = 256 * 1024;

2829
2930

const SKIP_GATEWAY_ENV = {

3031

NODE_ENV: "test",

@@ -431,6 +432,55 @@ export async function stopGatewayWithRuntime({

431432

}

432433

}

433434
435+

function responseBodyTooLargeError(label, maxBytes) {

436+

return new Error(`${label} response body exceeded ${maxBytes} bytes`);

437+

}

438+
439+

export async function readBoundedResponseText(response, label, maxBytes) {

440+

const contentLength = Number(response.headers.get("content-length") ?? "");

441+

if (Number.isSafeInteger(contentLength) && contentLength > maxBytes) {

442+

await response.body?.cancel().catch(() => undefined);

443+

throw responseBodyTooLargeError(label, maxBytes);

444+

}

445+
446+

if (!response.body) {

447+

return "";

448+

}

449+
450+

const reader = response.body.getReader();

451+

const decoder = new TextDecoder();

452+

const chunks = [];

453+

let totalBytes = 0;

454+

let canceled = false;

455+
456+

try {

457+

for (;;) {

458+

const { done, value } = await reader.read();

459+

if (done) {

460+

const tail = decoder.decode();

461+

if (tail) {

462+

chunks.push(tail);

463+

}

464+

break;

465+

}

466+
467+

totalBytes += value.byteLength;

468+

if (totalBytes > maxBytes) {

469+

canceled = true;

470+

await reader.cancel().catch(() => undefined);

471+

throw responseBodyTooLargeError(label, maxBytes);

472+

}

473+

chunks.push(decoder.decode(value, { stream: true }));

474+

}

475+

} finally {

476+

if (!canceled) {

477+

reader.releaseLock();

478+

}

479+

}

480+
481+

return chunks.join("");

482+

}

483+
434484

async function invokeMemorySearch({ port, token, timeoutMs }) {

435485

const controller = new AbortController();

436486

const timer = setTimeout(() => controller.abort(), timeoutMs);

@@ -453,7 +503,11 @@ async function invokeMemorySearch({ port, token, timeoutMs }) {

453503

}),

454504

signal: controller.signal,

455505

});

456-

const text = await res.text();

506+

const text = await readBoundedResponseText(

507+

res,

508+

"memory_search",

509+

MEMORY_SEARCH_RESPONSE_MAX_BYTES,

510+

);

457511

return {

458512

ok: res.ok,

459513

status: res.status,

Original file line numberDiff line numberDiff line change

@@ -2,8 +2,10 @@ import { EventEmitter } from "node:events";

22

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

33

import {

44

GATEWAY_READY_OUTPUT_MAX_CHARS,

5+

MEMORY_SEARCH_RESPONSE_MAX_BYTES,

56

hasChildExited,

67

parseArgs,

8+

readBoundedResponseText,

79

readNumber,

810

readPositiveNumber,

911

stopGatewayWithRuntime,

@@ -178,4 +180,44 @@ describe("check-memory-fd-repro", () => {

178180

expect(state.readySeen).toBe(true);

179181

expect(state.tail).toBe("w output");

180182

});

183+
184+

it("reads memory_search response bodies under the byte cap", async () => {

185+

await expect(

186+

readBoundedResponseText(

187+

new Response("ok"),

188+

"memory_search",

189+

MEMORY_SEARCH_RESPONSE_MAX_BYTES,

190+

),

191+

).resolves.toBe("ok");

192+

});

193+
194+

it("rejects oversized memory_search response bodies from content-length", async () => {

195+

const response = new Response("ignored", {

196+

headers: { "content-length": String(MEMORY_SEARCH_RESPONSE_MAX_BYTES + 1) },

197+

});

198+
199+

await expect(

200+

readBoundedResponseText(response, "memory_search", MEMORY_SEARCH_RESPONSE_MAX_BYTES),

201+

).rejects.toThrow(

202+

`memory_search response body exceeded ${MEMORY_SEARCH_RESPONSE_MAX_BYTES} bytes`,

203+

);

204+

});

205+
206+

it("stops reading memory_search response streams after the byte cap", async () => {

207+

const chunk = new Uint8Array(MEMORY_SEARCH_RESPONSE_MAX_BYTES + 1);

208+

const response = new Response(

209+

new ReadableStream({

210+

start(controller) {

211+

controller.enqueue(chunk);

212+

controller.close();

213+

},

214+

}),

215+

);

216+
217+

await expect(

218+

readBoundedResponseText(response, "memory_search", MEMORY_SEARCH_RESPONSE_MAX_BYTES),

219+

).rejects.toThrow(

220+

`memory_search response body exceeded ${MEMORY_SEARCH_RESPONSE_MAX_BYTES} bytes`,

221+

);

222+

});

181223

});