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

推荐订阅源

V
V2EX
aimingoo的专栏
aimingoo的专栏
S
SegmentFault 最新的问题
博客园_首页
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
IT之家
IT之家
博客园 - 【当耐特】
月光博客
月光博客
C
Check Point Blog
T
The Blog of Author Tim Ferriss
罗磊的独立博客
博客园 - Franky
MongoDB | Blog
MongoDB | Blog
H
Help Net Security
Microsoft Security Blog
Microsoft Security Blog
B
Blog
阮一峰的网络日志
阮一峰的网络日志
腾讯CDC
美团技术团队
N
Netflix TechBlog - Medium
Stack Overflow Blog
Stack Overflow Blog
Y
Y Combinator Blog
L
LangChain Blog
The Cloudflare Blog

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(tooling): bound RPC RTT readiness bodies · openclaw/o...
vincentkoc · 2026-06-19 · via Recent Commits to openclaw:main

@@ -9,13 +9,15 @@ import net from "node:net";

99

import path from "node:path";

1010

import { performance } from "node:perf_hooks";

1111

import { fileURLToPath, pathToFileURL } from "node:url";

12+

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

12131314

const DEFAULT_METHODS = ["health", "config.get"];

1415

const DEFAULT_ITERATIONS = 10;

1516

/** Maximum time to wait for a spawned gateway to become reachable. */

1617

export const READY_TIMEOUT_MS = 120_000;

1718

/** Per-probe timeout used while polling gateway readiness endpoints. */

1819

export const READY_PROBE_TIMEOUT_MS = 1_000;

20+

const READY_PROBE_RESPONSE_BODY_MAX_BYTES = 64 * 1024;

1921

const GATEWAY_FORCE_KILL_GRACE_MS = 250;

2022

const PARENT_TERMINATION_SIGNALS = ["SIGHUP", "SIGINT", "SIGTERM"];

2123

const IS_DIRECT_RUN =

@@ -126,21 +128,56 @@ function formatErrorMessage(error) {

126128

return String(error);

127129

}

128130129-

async function readyzReportsReady(response) {

131+

async function readyzReportsReady(response, options = {}) {

130132

if (!response.ok) {

131133

return false;

132134

}

133-

if (typeof response.json !== "function") {

134-

return false;

135-

}

136135

try {

137-

const body = await response.json();

136+

const text = await readBoundedResponseText(

137+

response,

138+

"RPC RTT /readyz",

139+

READY_PROBE_RESPONSE_BODY_MAX_BYTES,

140+

options,

141+

);

142+

const body = JSON.parse(text);

138143

return body && typeof body === "object" && body.ready === true;

139144

} catch {

140145

return false;

141146

}

142147

}

143148149+

async function fetchReadinessProbe(fetchImpl, url, timeoutMs) {

150+

const controller = new AbortController();

151+

const timeoutError = Object.assign(new Error(`${url} timed out after ${timeoutMs}ms`), {

152+

code: "ETIMEDOUT",

153+

});

154+

let timeout;

155+

const timeoutPromise = new Promise((_, reject) => {

156+

timeout = setTimeout(() => {

157+

controller.abort(timeoutError);

158+

reject(timeoutError);

159+

}, timeoutMs);

160+

timeout.unref?.();

161+

});

162+

try {

163+

const response = await Promise.race([

164+

fetchImpl(url, {

165+

signal: controller.signal,

166+

}),

167+

timeoutPromise,

168+

]);

169+

return {

170+

clearTimeout: () => clearTimeout(timeout),

171+

response,

172+

signal: controller.signal,

173+

timeoutPromise,

174+

};

175+

} catch (error) {

176+

clearTimeout(timeout);

177+

throw error;

178+

}

179+

}

180+144181

/**

145182

* Polls readiness endpoints while also failing fast if the child exits.

146183

*/

@@ -172,19 +209,33 @@ export async function waitForGatewayReady({

172209

);

173210

}

174211

try {

175-

const response = await fetchImpl(`http://127.0.0.1:${port}/readyz`, {

176-

signal: AbortSignal.timeout(probeTimeoutMs),

177-

});

178-

if (await readyzReportsReady(response)) {

179-

return;

212+

const probe = await fetchReadinessProbe(

213+

fetchImpl,

214+

`http://127.0.0.1:${port}/readyz`,

215+

probeTimeoutMs,

216+

);

217+

try {

218+

if (

219+

await readyzReportsReady(probe.response, {

220+

signal: probe.signal,

221+

timeoutPromise: probe.timeoutPromise,

222+

})

223+

) {

224+

return;

225+

}

226+

} finally {

227+

probe.clearTimeout();

180228

}

181229

} catch {

182230

// The gateway may not have bound the port yet.

183231

}

184232

try {

185-

await fetchImpl(`http://127.0.0.1:${port}/healthz`, {

186-

signal: AbortSignal.timeout(probeTimeoutMs),

187-

});

233+

const probe = await fetchReadinessProbe(

234+

fetchImpl,

235+

`http://127.0.0.1:${port}/healthz`,

236+

probeTimeoutMs,

237+

);

238+

probe.clearTimeout();

188239

} catch {

189240

// Liveness is diagnostic only; /readyz is the usable RPC readiness contract.

190241

}