diigo-cache: page size 100, diigo's cap; fill jobs record their page size

Asked for 128, diigo returned 100 (the short-page guard caught it on the
first real fill), so PAGE_SIZE = 100: ~168 pages for 16.7k bookmarks.

The same run showed a fill job outliving a page-size change: progress
counted in 24s ("page 25 of 698") resumed as if counted in 128s. Stored
state reinterpreted, so: FillStatus records pageSize (additive; jobs
saved without it counted in 24), and a job whose size differs from
PAGE_SIZE fails with "page size changed …; start the fill again"
instead of resuming; starting again replaces it. Tested with the old
shape in storage.

Generated-by: Claude Opus 5.5
This commit is contained in:
dckc committed 2026-10-07 04:59:39 -05:00
1 parent 3baffcab4c
commit 563cb83995
4 files changed
+60 -20

No files matched your search

+17 -2
View File
@@ -9,8 +9,8 @@ import { FIXED_NOW } from "./test-worker.js";
import { PAGE_SIZE } from "../src/cache.js";
// goal 1e (capsite checklist): a job that grabs every page. Fake
// accounts: tests/fake-webapp.js ("fake-webapp-id": 300 items = 3 pages
// of PAGE_SIZE 128, every 3rd private).
// accounts: tests/fake-webapp.js ("fake-webapp-id": 250 items = 3 pages
// of PAGE_SIZE 100, every 3rd private).
type TestEnv = {
CACHE_DO: DurableObjectNamespace<import("../src/index.js").DiigoCache>;
@@ -131,6 +131,21 @@ describe("fill job (goal 1e)", () => {
expect(status?.error).toMatch(/page size not honored/);
});
it("a job saved under another page size fails instead of resuming; a new start replaces it", async () => {
const stub = await wired();
// the shape a 24-per-page job left in storage (no pageSize field)
await runInDurableObject(stub, async (_obj, state) => {
const at = new Date().toISOString();
await state.storage.put("fill", { state: "running", nextPage: 25, pages: 698, fetched: 23, startedAt: at, updatedAt: at });
await state.storage.setAlarm(Date.now() + 60_000);
});
await drain(stub);
const stale = await stub.fillStatus();
expect(stale?.state).toBe("failed");
expect(stale?.error).toMatch(/page size changed \(from 24 to 100\)/);
expect(await stub.startFill()).toMatchObject({ state: "running", nextPage: 1, pageSize: PAGE_SIZE });
});
it("a public cache's fill stores no private rows", async () => {
const stub = testEnv.PUBLIC_DO.get(testEnv.PUBLIC_DO.newUniqueId());
await stub.setup({ webappId: "fake-webapp-id" });