fix(twitch): cancel auth retry disconnects · openclaw/openclaw@841cb12
steipete
·
2026-05-24
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -231,6 +231,17 @@ describe("TwitchClientManager", () => {
|
231 | 231 | await expect(connection).resolves.toBeTruthy(); |
232 | 232 | }); |
233 | 233 | |
| 234 | +it("rejects pending auth retry connections on manual disconnect", async () => { |
| 235 | +mockConnect.mockImplementationOnce(() => {}); |
| 236 | + |
| 237 | +const connection = manager.getClient(testAccount); |
| 238 | +await Promise.resolve(); |
| 239 | +authFailureHandlers[0]?.("bad token", 1); |
| 240 | +disconnectHandlers[0]?.(true); |
| 241 | + |
| 242 | +await expect(connection).rejects.toThrow("Twitch connection cancelled"); |
| 243 | +}); |
| 244 | + |
234 | 245 | it("does not cache pending connections after disconnectAll", async () => { |
235 | 246 | mockConnect.mockImplementationOnce(() => {}); |
236 | 247 | |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -231,14 +231,21 @@ export class TwitchClientManager {
|
231 | 231 | `Twitch authentication failed for ${account.username}; waiting for retry, disconnect, or timeout: ${text}`, |
232 | 232 | ); |
233 | 233 | }), |
234 | | -client.onDisconnect((_manual, reason) => { |
235 | | -if (authRetryPending) { |
| 234 | +client.onDisconnect((manual, reason) => { |
| 235 | +if (authRetryPending && !manual) { |
236 | 236 | this.logger.debug?.( |
237 | 237 | `Twitch disconnected during auth retry for ${account.username}: ${formatErrorMessage(reason)}`, |
238 | 238 | ); |
239 | 239 | return; |
240 | 240 | } |
241 | | -finish(reason ?? new Error(`Twitch disconnected before ready for ${account.username}`)); |
| 241 | +finish( |
| 242 | +reason ?? |
| 243 | +new Error( |
| 244 | +manual |
| 245 | + ? `Twitch connection cancelled for ${account.username}` |
| 246 | + : `Twitch disconnected before ready for ${account.username}`, |
| 247 | +), |
| 248 | +); |
242 | 249 | }), |
243 | 250 | ); |
244 | 251 | timeout = setTimeout( |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。