fix(provider): retry top-level network codes · openclaw/openclaw@9741bbe
steipete
·
2026-05-13
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -112,6 +112,25 @@ describe("executeWithApiKeyRotation", () => {
|
112 | 112 | expect(execute).toHaveBeenCalledTimes(2); |
113 | 113 | }); |
114 | 114 | |
| 115 | +it("retries selected transient network errors with top-level codes", async () => { |
| 116 | +const sleep = vi.fn(async () => undefined); |
| 117 | +const execute = vi |
| 118 | +.fn<(apiKey: string) => Promise<string>>() |
| 119 | +.mockRejectedValueOnce(Object.assign(new Error("socket hang up"), { code: "ECONNRESET" })) |
| 120 | +.mockResolvedValueOnce("ok"); |
| 121 | + |
| 122 | +await expect( |
| 123 | +executeWithApiKeyRotation({ |
| 124 | +provider: "deepgram", |
| 125 | +apiKeys: ["key-1"], |
| 126 | +transientRetry: { attempts: 2, baseDelayMs: 0, maxDelayMs: 0, sleep }, |
| 127 | + execute, |
| 128 | +}), |
| 129 | +).resolves.toBe("ok"); |
| 130 | + |
| 131 | +expect(execute).toHaveBeenCalledTimes(2); |
| 132 | +}); |
| 133 | + |
115 | 134 | it("does not retry caller-aborted AbortError", async () => { |
116 | 135 | const controller = new AbortController(); |
117 | 136 | controller.abort(new Error("user cancelled")); |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。