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

推荐订阅源

J
Java Code Geeks
Stack Overflow Blog
Stack Overflow Blog
B
Blog RSS Feed
C
Check Point Blog
D
Docker
Y
Y Combinator Blog
Recent Announcements
Recent Announcements
Google DeepMind News
Google DeepMind News
MongoDB | Blog
MongoDB | Blog
博客园_首页
Apple Machine Learning Research
Apple Machine Learning Research
量子位
有赞技术团队
有赞技术团队
IT之家
IT之家
大猫的无限游戏
大猫的无限游戏
D
DataBreaches.Net
M
MIT News - Artificial intelligence
B
Blog
阮一峰的网络日志
阮一峰的网络日志
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
腾讯CDC
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
V
V2EX
月光博客
月光博客

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(feishu): repair WebSocket reconnect and heartbeat con...
vincentkoc · 2026-04-28 · via Recent Commits to openclaw:main

@@ -38,6 +38,7 @@ function createWsClient(): MockWsClient {

3838

}

39394040

afterEach(() => {

41+

vi.useRealTimers();

4142

stopFeishuMonitorState();

4243

vi.clearAllMocks();

4344

});

@@ -79,6 +80,98 @@ describe("feishu websocket cleanup", () => {

7980

expect(botNames.has(accountId)).toBe(false);

8081

});

818283+

it("retries with backoff after websocket start rejects", async () => {

84+

vi.useFakeTimers();

85+

const failedClient = createWsClient();

86+

failedClient.start.mockRejectedValueOnce(

87+

new Error("connect failed\nAuthorization: Bearer token_abc appSecret=secret_abc"),

88+

);

89+

const recoveredClient = createWsClient();

90+

createFeishuWSClientMock

91+

.mockResolvedValueOnce(failedClient)

92+

.mockResolvedValueOnce(recoveredClient);

93+94+

const abortController = new AbortController();

95+

const runtime = {

96+

log: vi.fn(),

97+

error: vi.fn(),

98+

exit: vi.fn(),

99+

};

100+

const accountId = "retry";

101+102+

const monitorPromise = monitorWebSocket({

103+

account: createAccount(accountId),

104+

accountId,

105+

runtime,

106+

abortSignal: abortController.signal,

107+

eventDispatcher: {} as never,

108+

});

109+110+

await vi.waitFor(() => {

111+

expect(failedClient.start).toHaveBeenCalledTimes(1);

112+

expect(failedClient.close).toHaveBeenCalledTimes(1);

113+

expect(wsClients.has(accountId)).toBe(false);

114+

});

115+116+

await vi.advanceTimersByTimeAsync(1_000);

117+118+

await vi.waitFor(() => {

119+

expect(recoveredClient.start).toHaveBeenCalledTimes(1);

120+

expect(wsClients.get(accountId)).toBe(recoveredClient);

121+

});

122+123+

abortController.abort();

124+

await monitorPromise;

125+126+

expect(createFeishuWSClientMock).toHaveBeenCalledTimes(2);

127+

expect(recoveredClient.close).toHaveBeenCalledTimes(1);

128+

expect(runtime.error).toHaveBeenCalledWith(

129+

expect.stringContaining("WebSocket start failed, retrying in 1000ms"),

130+

);

131+

const errorMessage = String(runtime.error.mock.calls[0]?.[0] ?? "");

132+

expect(errorMessage).not.toContain("\n");

133+

expect(errorMessage).not.toContain("token_abc");

134+

expect(errorMessage).not.toContain("secret_abc");

135+

expect(errorMessage).toContain("Authorization: Bearer [redacted]");

136+

expect(errorMessage).toContain("appSecret=[redacted]");

137+

});

138+139+

it("redacts websocket close errors during abort cleanup", async () => {

140+

const wsClient = createWsClient();

141+

wsClient.close.mockImplementationOnce(() => {

142+

throw new Error("close failed\naccess_token=secret_token");

143+

});

144+

createFeishuWSClientMock.mockReturnValue(wsClient);

145+146+

const abortController = new AbortController();

147+

const runtime = {

148+

log: vi.fn(),

149+

error: vi.fn(),

150+

exit: vi.fn(),

151+

};

152+153+

const monitorPromise = monitorWebSocket({

154+

account: createAccount("close-error"),

155+

accountId: "close-error",

156+

runtime,

157+

abortSignal: abortController.signal,

158+

eventDispatcher: {} as never,

159+

});

160+161+

await vi.waitFor(() => {

162+

expect(wsClient.start).toHaveBeenCalledTimes(1);

163+

});

164+165+

abortController.abort();

166+

await monitorPromise;

167+168+

const errorMessage = String(runtime.error.mock.calls[0]?.[0] ?? "");

169+

expect(errorMessage).toContain("error closing WebSocket client");

170+

expect(errorMessage).toContain("access_token=[redacted]");

171+

expect(errorMessage).not.toContain("\n");

172+

expect(errorMessage).not.toContain("secret_token");

173+

});

174+82175

it("closes targeted websocket clients during stop cleanup", () => {

83176

const alphaClient = createWsClient();

84177

const betaClient = createWsClient();