test(wal-heal): await the heal open() started instead of a wall clock (#2056)

`open() itself kicks off the heal` polled the WAL size for 30s and then
asserted it. On a loaded machine the heal was still running when the
deadline passed, so a slow heal failed as a size assertion, reading like a
regression (#1773). Await the pass open() started instead: it still fails
at once if open() stops kicking off the heal, and reports the heal's own
result rather than the clock's.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Colby Mchenry
2026-09-27 19:55:37 +00:00
committed by GitHub
co-authored by Claude Opus 5.5
parent 66aebd17e2
commit e63fe2ec5b
+6 -4
View File
@@ -158,10 +158,12 @@ describe('WAL heal after killed sessions (#1431)', () => {
const conn = DatabaseConnection.open(dbPath); // fire-and-forget heal
try {
const deadline = Date.now() + 30_000;
while (walSize() > WAL_HEAL_THRESHOLD_BYTES && Date.now() < deadline) {
await new Promise((r) => setTimeout(r, 200));
}
// Private-field peek: the pass open() started. Awaiting it, instead of
// polling the file against a 30s wall clock, keeps a loaded machine from
// reporting a heal that is still running as a heal that failed (#1773).
const started = (conn as unknown as { walHeal: Promise<{ afterBytes: number }> | null }).walHeal;
expect(started).not.toBeNull();
expect((await started!).afterBytes).toBeLessThanOrEqual(WAL_HEAL_THRESHOLD_BYTES);
expect(walSize()).toBeLessThanOrEqual(WAL_HEAL_THRESHOLD_BYTES);
} finally {
conn.close();