diff --git a/apps/server/src/usage/UsageService.test.ts b/apps/server/src/usage/UsageService.test.ts index 68d2e7c2bbf6d7938cb2bbf74f288be9c1ab4210..9c1e62fe1a7d395502c1e15d2f665eed05104e72 100644 --- a/apps/server/src/usage/UsageService.test.ts +++ b/apps/server/src/usage/UsageService.test.ts @@ -1175,7 +1175,8 @@ describe("UsageService", () => { return text; }); - const summary = yield* (yield* UsageService.make).readSummary(WINDOW); + const restarted = yield* UsageService.make; + const summary = yield* restarted.readSummary(WINDOW); // The live rollout re-parses at the ultrafast rate (10 x 6); the // deleted one keeps its saved v4 usage at the standard rate (20 x 1). assert.strictEqual(totalOutputTokens(summary), 30); @@ -1188,6 +1189,9 @@ describe("UsageService", () => { yield* Effect.promise(() => NodeFSP.readFile(legacyPath, "utf8")), legacy, ); + // The migrated cache is written in the background; let it land before + // the layer removes the state directory under it. + yield* restarted.awaitPersisted; }).pipe( Effect.provide( layerService({