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

Sentinel: shared:01m23vygyffx5hg2f5vm8r74sr:1p9qyksd9g is past its budget: trevato/forge: "the page with 150 repositories costs a handful of statements, not one per repository" failed on 3 pulls… #9300

Merged opened this

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

Merged

scout/forge:scout/9299-sentinel-shared-01m23vygyffx5hg2f5vm8r74 → main 3 commits fork

  • Merged. scout/9299-sentinel-shared-01m23vygyffx5hg2f5vm8r74 was merged into main as 00c9813.

Review

Sign in to review this change.
2 files changed +31 −4
test/helpers/statements.ts +12 −4
@@ -15,6 +15,11 @@
1515 * real N+1 costs more in every run, so the minimum still shows it; noise
1616 * costs more in some runs, so the minimum drops it.
1717 *
18 * The waits read `performance.now()`, never `Date.now()`: a test file earlier in
19 * the same process that leaves the wall clock frozen (`setSystemTime`, a spy)
20 * would otherwise stop `quiet` ever seeing time pass and hang the test for its
21 * whole timeout (#9299: 60 s, on three pulls, only beside other files).
22 *
1823 * `work` must be repeatable: a request for the same page, not a mutation.
1924 */
2025
@@ -50,15 +55,18 @@ async function once(
5055 export async function quiet(db: Database): Promise<void> {
5156 const door = db as unknown as Door;
5257 const original = db.query.bind(db);
53 let last = Date.now();
58 let last = performance.now();
5459 door.query = (sql: string) => {
55 last = Date.now();
60 last = performance.now();
5661 return original(sql);
5762 };
5863 try {
59 const started = Date.now();
60 while (Date.now() - last < QUIET_MS && Date.now() - started < GIVE_UP_MS)
64 const started = performance.now();
65 for (;;) {
66 const now = performance.now();
67 if (now - last >= QUIET_MS || now - started >= GIVE_UP_MS) break;
6168 await new Promise((resolve) => setTimeout(resolve, QUIET_MS / 4));
69 }
6270 } finally {
6371 door.query = original;
6472 }
test/statements-frozen-clock.test.ts added +19
@@ -0,0 +1,19 @@
1 /** The statement counter's waits do not hang when an earlier file left the wall clock frozen (#9299). */
2
3 import { Database } from "bun:sqlite";
4 import { afterEach, expect, setSystemTime, test } from "bun:test";
5 import { quiet, statements } from "./helpers/statements.ts";
6
7 afterEach(() => setSystemTime());
8
9 test("quiet and statements return on a frozen wall clock", async () => {
10 setSystemTime(new Date("2026-01-01T00:00:00Z"));
11 const db = new Database(":memory:");
12 const t0 = performance.now();
13 await quiet(db);
14 const n = await statements(db, () => {
15 db.query("select 1").get();
16 });
17 expect(n).toBe(1);
18 expect(performance.now() - t0).toBeLessThan(2_000);
19 }, 10_000);

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs