fix(gateway): avoid caching empty model catalogs · openclaw/openclaw@6689e41
clawsweeper
·
2026-04-30
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -47,6 +47,24 @@ describe("loadGatewayModelCatalog", () => {
|
47 | 47 | expect(loadModelCatalog).toHaveBeenCalledTimes(1); |
48 | 48 | }); |
49 | 49 | |
| 50 | +it("does not cache an empty catalog so the next request retries", async () => { |
| 51 | +const emptyCatalog: GatewayModelChoice[] = []; |
| 52 | +const freshCatalog = [model("gpt-5.5")]; |
| 53 | +const loadModelCatalog = vi |
| 54 | +.fn<LoadModelCatalogForTest>() |
| 55 | +.mockResolvedValueOnce(emptyCatalog) |
| 56 | +.mockResolvedValueOnce(freshCatalog); |
| 57 | + |
| 58 | +await expect(loadGatewayModelCatalog({ getConfig, loadModelCatalog })).resolves.toBe( |
| 59 | +emptyCatalog, |
| 60 | +); |
| 61 | +await expect(loadGatewayModelCatalog({ getConfig, loadModelCatalog })).resolves.toBe( |
| 62 | +freshCatalog, |
| 63 | +); |
| 64 | + |
| 65 | +expect(loadModelCatalog).toHaveBeenCalledTimes(2); |
| 66 | +}); |
| 67 | + |
50 | 68 | it("returns the last catalog while a stale reload refresh is still pending", async () => { |
51 | 69 | const staleCatalog = [model("gpt-5.4")]; |
52 | 70 | const freshCatalog = [model("gpt-5.5")]; |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。