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

推荐订阅源

奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
小众软件
小众软件
博客园 - 三生石上(FineUI控件)
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
博客园_首页
Last Week in AI
Last Week in AI
美团技术团队
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Apple Machine Learning Research
Apple Machine Learning Research
WordPress大学
WordPress大学
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - Franky
The Cloudflare Blog
罗磊的独立博客
月光博客
月光博客
N
Netflix TechBlog - Medium
C
Check Point Blog
Microsoft Security Blog
Microsoft Security Blog
F
Fortinet All Blogs
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Microsoft Azure Blog
Microsoft Azure Blog
IT之家
IT之家
Jina AI
Jina AI
J
Java Code Geeks

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
refactor: share e2e bounded response reader · openclaw/op...
vincentkoc · 2026-05-30 · via Recent Commits to openclaw:main
Original file line numberDiff line numberDiff line change

@@ -23,7 +23,9 @@ export async function readBoundedResponseText(response, label, byteLimit, timeou

2323

let text = "";

2424

try {

2525

while (true) {

26-

const { done, value } = await Promise.race([reader.read(), timeoutPromise]);

26+

const { done, value } = await (timeoutPromise

27+

? Promise.race([reader.read(), timeoutPromise])

28+

: reader.read());

2729

if (done) {

2830

return text + decoder.decode();

2931

}

Original file line numberDiff line numberDiff line change

@@ -4,6 +4,7 @@ import {

44

assertAgentReplyContainsMarker,

55

assertOpenAiRequestLogUsed,

66

} from "../agent-turn-output.mjs";

7+

import { readBoundedResponseText as readBoundedResponseTextWithLimit } from "../bounded-response-text.mjs";

78

import { applyMockOpenAiModelConfig } from "../fixtures/mock-openai-config.mjs";

89
910

const command = process.argv[2];

@@ -46,49 +47,12 @@ async function withClickClackFixtureResponse(url, init, consume, options = {}) {

4647

}

4748

}

4849
49-

function bodyTooLargeError(label, byteLimit) {

50-

return Object.assign(new Error(`${label} response body exceeded ${byteLimit} bytes`), {

51-

code: "ETOOBIG",

52-

});

53-

}

54-
5550

async function readBoundedResponseText(

5651

response,

5752

label,

5853

byteLimit = CLICKCLACK_HTTP_BODY_MAX_BYTES,

5954

) {

60-

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

61-

if (contentLength) {

62-

const parsedLength = Number(contentLength);

63-

if (Number.isSafeInteger(parsedLength) && parsedLength > byteLimit) {

64-

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

65-

throw bodyTooLargeError(label, byteLimit);

66-

}

67-

}

68-

if (!response.body) {

69-

return "";

70-

}

71-
72-

const reader = response.body.getReader();

73-

const decoder = new TextDecoder();

74-

let byteCount = 0;

75-

let text = "";

76-

try {

77-

while (true) {

78-

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

79-

if (done) {

80-

return text + decoder.decode();

81-

}

82-

byteCount += value.byteLength;

83-

if (byteCount > byteLimit) {

84-

await reader.cancel().catch(() => {});

85-

throw bodyTooLargeError(label, byteLimit);

86-

}

87-

text += decoder.decode(value, { stream: true });

88-

}

89-

} finally {

90-

reader.releaseLock();

91-

}

55+

return await readBoundedResponseTextWithLimit(response, label, byteLimit);

9256

}

9357
9458

async function readBoundedResponseJson(response, label) {

Original file line numberDiff line numberDiff line change

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

11

import { Agent, setGlobalDispatcher } from "undici";

2+

import { readBoundedResponseText as readBoundedResponseTextWithLimit } from "./lib/bounded-response-text.mjs";

23
34

const baseUrl = process.env.OPENWEBUI_BASE_URL ?? "";

45

const email = process.env.OPENWEBUI_ADMIN_EMAIL ?? "";

@@ -69,12 +70,6 @@ function createTimeoutError(label, timeoutMs) {

6970

return error;

7071

}

7172
72-

function createBodyTooLargeError(label, byteLimit) {

73-

const error = new Error(`${label} response body exceeded ${byteLimit} bytes`);

74-

error.code = "ETOOBIG";

75-

return error;

76-

}

77-
7873

async function withRequestTimeout(label, timeoutMs, run) {

7974

const controller = new AbortController();

8075

const timeoutError = createTimeoutError(label, timeoutMs);

@@ -95,38 +90,7 @@ async function withRequestTimeout(label, timeoutMs, run) {

9590

}

9691
9792

async function readBoundedResponseText(response, label, byteLimit = responseBodyMaxBytes) {

98-

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

99-

if (contentLength) {

100-

const parsedLength = Number(contentLength);

101-

if (Number.isSafeInteger(parsedLength) && parsedLength > byteLimit) {

102-

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

103-

throw createBodyTooLargeError(label, byteLimit);

104-

}

105-

}

106-

if (!response.body) {

107-

return "";

108-

}

109-
110-

const reader = response.body.getReader();

111-

const decoder = new TextDecoder();

112-

let byteCount = 0;

113-

let text = "";

114-

try {

115-

while (true) {

116-

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

117-

if (done) {

118-

return text + decoder.decode();

119-

}

120-

byteCount += value.byteLength;

121-

if (byteCount > byteLimit) {

122-

await reader.cancel().catch(() => {});

123-

throw createBodyTooLargeError(label, byteLimit);

124-

}

125-

text += decoder.decode(value, { stream: true });

126-

}

127-

} finally {

128-

reader.releaseLock();

129-

}

93+

return await readBoundedResponseTextWithLimit(response, label, byteLimit);

13094

}

13195
13296

async function readBoundedResponseJson(response, label) {