Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): keep usage-limits incomplete after sparse post-probe updates #12700

Closedmacodev00(GitHub profile, opens in a new tab)wants to merge 1 commit intomain fromrefs/pull/12700/headopened View on GitHub

Showing 2 changed files with 50 additions and 2 deletions.

x
0 of 2 viewed, 2 left
39 additions and 0 deletionsapps/server/src/provider/providerUsageLimits.test.tsModified
View file
@@ -62,6 +62,35 @@
).toBe(published);
});
​
+ it("keeps a failed probe marked when a sparse update lands on it", () => {
+ // A `rate_limit_event` names one window. Merged onto a failed probe it
+ // must not read as the full set, or a later failed probe keeps it as last-good.
+ const failed = {
+ checkedAt,
+ windows: [],
+ unavailable: { reason: "probeFailed" as const, message: "usage timed out" },
+ };
+ const next = applyUsageLimitsUpdate({
+ previous: failed,
+ checkedAt: "2026-09-03T12:00:05.000Z",
+ update: { windows: [weekly] },
+ });
+ expect(next).toEqual({
+ checkedAt: "2026-09-03T12:00:05.000Z",
+ windows: [weekly],
+ unavailable: failed.unavailable,
+ });
+ expect(
+ applyUsageLimitsUpdate({ previous: next, checkedAt, update: { windows: [weekly] } }),
+ ).toBe(next);
+ });
+​
+ it("marks a sparse update with no previous snapshot as probeFailed", () => {
+ expect(
+ applyUsageLimitsUpdate({ previous: undefined, checkedAt, update: { windows: [weekly] } }),