Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): a refused hub read keeps the account's last good usage reading #38397

MergedKrarilotus(GitHub profile, opens in a new tab)merged 7 commits intomain fromrefs/pull/38397/headmerged by juliusmarminge View on GitHub

Showing 2 changed files with 138 additions and 1 deletion.

x
0 of 2 viewed, 2 left
101 additions and 0 deletionsapps/server/src/usage/UsageLimitSources.test.tsModified
View file
@@ -175,6 +175,107 @@
});
​
+it.effect("keeps an account's last good reading when the hub's next read of it is refused", () => {
+ let refused = true;
+ let workspace = "account-a";
+ let listsIdentity = true;
+ const readAccount = Effect.gen(function* () {
+ const sources = yield* UsageLimitSources.make;
+ return Effect.gen(function* () {
+ yield* sources.refresh;
+ const [source] = yield* sources.current;
+ return source?.accounts[0]?.usageLimits;
+ });
+ });
+ return Effect.gen(function* () {
+ const read = yield* readAccount;
+ // Nothing to keep yet: the account stays listed as unreadable.
+ expect(yield* read).toMatchObject({ windows: [], unavailable: { reason: "probeFailed" } });
+ refused = false;
+ const good = yield* read;
+ expect(good?.windows.map((window) => window.usedPercent)).toEqual([78]);
+ expect(good?.unavailable).toBeUndefined();
+ refused = true;
+ expect(yield* read).toEqual(good);
+ // The same auth file now holds another login, whose reading is unknown.
+ workspace = "account-b";
+ expect(yield* read).toMatchObject({ windows: [], unavailable: { reason: "probeFailed" } });
+ // A file that lists no login cannot show whether the next one is the same.