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

推荐订阅源

美团技术团队
IT之家
IT之家
博客园 - Franky
博客园_首页
The Cloudflare Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
量子位
阮一峰的网络日志
阮一峰的网络日志
月光博客
月光博客
V
V2EX
Hugging Face - Blog
Hugging Face - Blog
博客园 - 三生石上(FineUI控件)
M
MIT News - Artificial intelligence
Engineering at Meta
Engineering at Meta
GbyAI
GbyAI
Stack Overflow Blog
Stack Overflow Blog
小众软件
小众软件
Jina AI
Jina AI
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
博客园 - 叶小钗
Apple Machine Learning Research
Apple Machine Learning Research
B
Blog RSS Feed

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(gateway): tolerate transient pre-hello clean closes (...
vincentkoc · 2026-06-16 · via Recent Commits to openclaw:main

@@ -75,7 +75,7 @@ let lastClientOptions: {

7575

scopes?: string[];

7676

deviceIdentity?: unknown;

7777

onHelloOk?: (hello: { features?: { methods?: string[] } }) => void | Promise<void>;

78-

onClose?: (code: number, reason: string) => void;

78+

onClose?: (code: number, reason: string, info?: StubGatewayClientCloseInfo) => void;

7979

onConnectError?: (err: Error) => void;

8080

} | null = null;

8181

let lastRequestOptions: {

@@ -88,7 +88,18 @@ let lastRequestOptions: {

8888

onAccepted?: (payload: unknown) => void;

8989

};

9090

} | null = null;

91-

type StartMode = "hello" | "close" | "connect-error" | "silent" | "startup-retry-then-hello";

91+

type StartMode =

92+

| "hello"

93+

| "close"

94+

| "connect-error"

95+

| "silent"

96+

| "startup-retry-then-hello"

97+

| "clean-prehello-close-then-hello"

98+

| "repeated-clean-prehello-close";

99+

type StubGatewayClientCloseInfo = {

100+

phase: "pre-hello" | "post-hello";

101+

transientPreHelloCleanClose: boolean;

102+

};

92103

let startMode: StartMode = "hello";

93104

let startCalls = 0;

94105

let closeCode = 1006;

@@ -119,7 +130,7 @@ vi.mock("./client.js", () => ({

119130

approvalRuntimeToken?: string;

120131

scopes?: string[];

121132

onHelloOk?: (hello: { features?: { methods?: string[] } }) => void | Promise<void>;

122-

onClose?: (code: number, reason: string) => void;

133+

onClose?: (code: number, reason: string, info?: StubGatewayClientCloseInfo) => void;

123134

onConnectError?: (err: Error) => void;

124135

}) {

125136

lastClientOptions = opts;

@@ -146,6 +157,25 @@ vi.mock("./client.js", () => ({

146157

methods: helloMethods,

147158

},

148159

});

160+

} else if (startMode === "clean-prehello-close-then-hello") {

161+

lastClientOptions?.onClose?.(1000, "", {

162+

phase: "pre-hello",

163+

transientPreHelloCleanClose: true,

164+

});

165+

void lastClientOptions?.onHelloOk?.({

166+

features: {

167+

methods: helloMethods,

168+

},

169+

});

170+

} else if (startMode === "repeated-clean-prehello-close") {

171+

lastClientOptions?.onClose?.(1000, "", {

172+

phase: "pre-hello",

173+

transientPreHelloCleanClose: true,

174+

});

175+

lastClientOptions?.onClose?.(1000, "", {

176+

phase: "pre-hello",

177+

transientPreHelloCleanClose: true,

178+

});

149179

} else if (startMode === "connect-error") {

150180

lastClientOptions?.onConnectError?.(

151181

connectError ?? connectAssemblyErrorState.create("device private key invalid"),

@@ -191,7 +221,7 @@ class StubGatewayClient {

191221

mode?: string;

192222

scopes?: string[];

193223

onHelloOk?: (hello: { features?: { methods?: string[] } }) => void | Promise<void>;

194-

onClose?: (code: number, reason: string) => void;

224+

onClose?: (code: number, reason: string, info?: StubGatewayClientCloseInfo) => void;

195225

onConnectError?: (err: Error) => void;

196226

}) {

197227

lastClientOptions = opts;

@@ -223,6 +253,25 @@ class StubGatewayClient {

223253

methods: helloMethods,

224254

},

225255

});

256+

} else if (startMode === "clean-prehello-close-then-hello") {

257+

lastClientOptions?.onClose?.(1000, "", {

258+

phase: "pre-hello",

259+

transientPreHelloCleanClose: true,

260+

});

261+

void lastClientOptions?.onHelloOk?.({

262+

features: {

263+

methods: helloMethods,

264+

},

265+

});

266+

} else if (startMode === "repeated-clean-prehello-close") {

267+

lastClientOptions?.onClose?.(1000, "", {

268+

phase: "pre-hello",

269+

transientPreHelloCleanClose: true,

270+

});

271+

lastClientOptions?.onClose?.(1000, "", {

272+

phase: "pre-hello",

273+

transientPreHelloCleanClose: true,

274+

});

226275

} else if (startMode === "connect-error") {

227276

lastClientOptions?.onConnectError?.(

228277

connectError ?? connectAssemblyErrorState.create("device private key invalid"),

@@ -1362,6 +1411,30 @@ describe("callGateway error details", () => {

13621411

expect(lastRequestOptions?.method).toBe("health");

13631412

});

136414131414+

it("keeps the request alive through one transient pre-hello clean close", async () => {

1415+

startMode = "clean-prehello-close-then-hello";

1416+

setLocalLoopbackGatewayConfig();

1417+1418+

await expect(callGateway({ method: "health" })).resolves.toEqual({ ok: true });

1419+1420+

expect(lastRequestOptions?.method).toBe("health");

1421+

});

1422+1423+

it("surfaces repeated transient pre-hello clean closes", async () => {

1424+

startMode = "repeated-clean-prehello-close";

1425+

setLocalLoopbackGatewayConfig();

1426+1427+

let err: Error | null = null;

1428+

try {

1429+

await callGateway({ method: "health" });

1430+

} catch (caught) {

1431+

err = caught as Error;

1432+

}

1433+1434+

expect(err?.message).toContain("gateway closed (1000 normal closure): no close reason");

1435+

expect(lastRequestOptions).toBeNull();

1436+

});

1437+13651438

it("rejects immediately when the client reports a connect error", async () => {

13661439

startMode = "connect-error";

13671440

setLocalLoopbackGatewayConfig();