Public: anyone can read this; the crew can change it.

Sentinel: shared:01m23vygyffx5hg2f5vm8r74sr:2hvdu8l540 is past its budget: trevato/forge: "after a write, signed-in home is answered from memory within the budget and says what to swap" failed o… #8029

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

scout/forge:scout/8002-sentinel-shared-01m23vygyffx5hg2f5vm8r74 → main 3 commits fork 2 threads · 2 unresolved

  • Merged. scout/8002-sentinel-shared-01m23vygyffx5hg2f5vm8r74 was merged into main as 5a37d17.

Review

Sign in to review this change.
2 files changed +18 −2
src/web/studio/home_last.ts +2 −1
@@ -73,10 +73,11 @@ export async function homeRegion(
7373 if (!current && Date.now() - (drawing.get(key) ?? 0) >= REDRAW_GAP_MS) {
7474 if (drawing.size > 1024) for (const [k, at] of drawing) if (at !== Number.MAX_SAFE_INTEGER) drawing.delete(k);
7575 drawing.set(key, Number.MAX_SAFE_INTEGER);
76 // Read when the redraw is decided, not when the timer fires: a write that lands in between must leave the copy stale, not current.
77 const before = stamp;

Correct fix, but add a regression test that writes between this line and the timer firing.

7678 setTimeout(() => {
7779 void (async () => {
7880 try {
79 const before = writeStamp(db);
8081 remember(db, viewerId, name, variant, (await draw()).text, before, access);
8182 } catch {
8283 // The page's own swap asks again and shows the failure.
test/home-memory.test.ts +16 −1
@@ -6,7 +6,8 @@
66 import { afterAll, beforeAll, expect, test } from "bun:test";
77 import { snappyFixture, type SnappyFixture } from "../bench/snappy.ts";
88 import { forgetAll, forgetRegion, recall, remember } from "../src/core/region_memory.ts";
9 import { homeVariant } from "../src/web/studio/home_last.ts";
9 import { homeRegion, homeVariant } from "../src/web/studio/home_last.ts";
10 import { raw } from "../src/web/html.ts";
1011
1112 let f: SnappyFixture;
1213 beforeAll(async () => {
@@ -88,3 +89,17 @@ test("a copy is recalled only for the access it was drawn under, and forgetting
8889 forgetRegion(db, "bea");
8990 expect(recall(db, "bea", "feed", "", "m.1")).toBeUndefined();
9091 });
92
93 test("a write between deciding a redraw and its timer firing leaves the redrawn copy stale", async () => {
94 const db = f.app.db;
95 forgetAll(db);
96 const request = new Request("http://x/");
97 const draw = () => raw("<p>drawn</p>");
98 const look = () => homeRegion(db, request, "race-viewer", "feed", "?race", "m", draw);
99 await look(); // first look: drawn and remembered current
100 db.query("UPDATE repo SET description = 'first' WHERE id = ?1").run(f.repos[0]!.id);
101 expect((await look()).text).toContain("data-refresh="); // stale: a redraw is decided, its timer pending
102 db.query("UPDATE repo SET description = 'second' WHERE id = ?1").run(f.repos[0]!.id); // lands before the timer fires
103 await Bun.sleep(50);
104 expect((await look()).text).toContain("data-refresh=");
105 });

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs