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

推荐订阅源

Jina AI
Jina AI
T
The Blog of Author Tim Ferriss
B
Blog
L
LangChain Blog
Y
Y Combinator Blog
美团技术团队
博客园 - 三生石上(FineUI控件)
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
G
Google Developers Blog
量子位
博客园_首页
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
C
Check Point Blog
D
Docker
小众软件
小众软件
The Cloudflare Blog
大猫的无限游戏
大猫的无限游戏
T
Tailwind CSS Blog
Apple Machine Learning Research
Apple Machine Learning Research
博客园 - 聂微东
Blog — PlanetScale
Blog — PlanetScale
GbyAI
GbyAI
Google DeepMind News
Google DeepMind News
IT之家
IT之家

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): bound OpenWebUI probe response bodies · opencla...
vincentkoc · 2026-05-29 · via Recent Commits to openclaw:main

@@ -13,6 +13,7 @@ const controlTimeoutMs = readPositiveInt(

1313

Math.min(fetchTimeoutMs, 30000),

1414

);

1515

const chatTimeoutMs = readPositiveInt("OPENWEBUI_CHAT_TIMEOUT_MS", fetchTimeoutMs);

16+

const responseBodyMaxBytes = readPositiveInt("OPENWEBUI_RESPONSE_BODY_MAX_BYTES", 1024 * 1024);

1617

const smokeMode =

1718

process.env.OPENWEBUI_SMOKE_MODE ?? process.env.OPENCLAW_OPENWEBUI_SMOKE_MODE ?? "chat";

1819

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

6869

return error;

6970

}

707172+

function createBodyTooLargeError(label, byteLimit) {

73+

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

74+

error.code = "ETOOBIG";

75+

return error;

76+

}

77+7178

async function withRequestTimeout(label, timeoutMs, run) {

7279

const controller = new AbortController();

7380

const timeoutError = createTimeoutError(label, timeoutMs);

@@ -87,6 +94,51 @@ async function withRequestTimeout(label, timeoutMs, run) {

8794

}

8895

}

899697+

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+

}

130+

}

131+132+

async function readBoundedResponseJson(response, label) {

133+

const body = await readBoundedResponseText(response, label);

134+

try {

135+

return JSON.parse(body);

136+

} catch (error) {

137+

const message = error instanceof Error ? error.message : String(error);

138+

throw new Error(`${label} returned invalid JSON: ${message}`, { cause: error });

139+

}

140+

}

141+90142

function getCookieHeader(res) {

91143

const raw = res.headers.get("set-cookie");

92144

if (!raw) {

@@ -125,12 +177,12 @@ async function fetchSignin() {

125177

signal,

126178

});

127179

if (!response.ok) {

128-

const body = await response.text();

180+

const body = await readBoundedResponseText(response, "Open WebUI signin");

129181

throw new Error(`signin failed: HTTP ${response.status} ${body}`);

130182

}

131183

return {

132184

cookie: getCookieHeader(response),

133-

json: await response.json(),

185+

json: await readBoundedResponseJson(response, "Open WebUI signin"),

134186

};

135187

});

136188

}

@@ -145,11 +197,14 @@ async function fetchModels(authHeaders, attempt) {

145197

return {

146198

ok: false,

147199

status: response.status,

148-

text: await response.text(),

200+

text: await readBoundedResponseText(

201+

response,

202+

`Open WebUI models attempt ${attempt}`,

203+

),

149204

};

150205

}

151206

return {

152-

json: await response.json(),

207+

json: await readBoundedResponseJson(response, `Open WebUI models attempt ${attempt}`),

153208

ok: true,

154209

};

155210

},

@@ -171,11 +226,12 @@ async function fetchChatCompletion(authHeaders, targetModel) {

171226

signal,

172227

});

173228

if (!response.ok) {

229+

const body = await readBoundedResponseText(response, "Open WebUI chat completion");

174230

throw new Error(

175-

`/api/chat/completions failed: HTTP ${response.status} ${await response.text()}`,

231+

`/api/chat/completions failed: HTTP ${response.status} ${body}`,

176232

);

177233

}

178-

return await response.json();

234+

return await readBoundedResponseJson(response, "Open WebUI chat completion");

179235

});

180236

}

181237