Skip to content

Commit 0546e04

Browse files
committed
fix(e2e): wait for pi compartment_in_progress to clear after publish
CI run 26104810358 caught a pre-existing race in the Pi historian success-path test: the compartment row appears the moment historian's publish transaction commits, but `compartment_in_progress` is cleared in the runner's `finally` block AFTER all post-publish work (memory promotion, drop queueing, compaction marker, compressor pass). On shared GitHub runners that gap can stretch beyond the 300ms initial sleep, so the assertion fires while the flag is still 1. The fix wraps the second assertion in a `waitFor` polling the same flag with a 60s timeout. The seeing-the-row check already uses `waitFor`; this just extends the same pattern to the in-progress flag that lands later in the same code path. Not a production regression — it's the test's wait window that's too short, not the runner.
1 parent 9447279 commit 0546e04

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

packages/e2e-tests/tests/pi-historian-success.test.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,26 @@ describe("pi historian success path", () => {
162162
console.log(`[TEST] pi historian requests: ${historianRequests.length}`);
163163
expect(historianRequests.length).toBeGreaterThanOrEqual(1);
164164

165+
// Wait for the runner to fully exit — compartment_in_progress is
166+
// cleared in the runner's `finally` block AFTER post-publish work
167+
// (memory promotion, queue drops, compaction marker, compressor).
168+
// The compartment row appears earlier in the flow, so seeing the
169+
// row doesn't guarantee the flag has flipped yet. On shared CI
170+
// runners the gap between publish and `finally` can stretch
171+
// beyond the initial 300ms sleep.
172+
await h.waitFor(
173+
() => {
174+
const meta = h
175+
.contextDb()
176+
.prepare(
177+
"SELECT compartment_in_progress FROM session_meta WHERE session_id = ?",
178+
)
179+
.get(sessionId) as { compartment_in_progress: number } | null;
180+
return (meta?.compartment_in_progress ?? 1) === 0;
181+
},
182+
{ timeoutMs: 60_000, label: "pi compartment_in_progress clears" },
183+
);
184+
165185
const meta = h
166186
.contextDb()
167187
.prepare("SELECT compartment_in_progress FROM session_meta WHERE session_id = ?")

0 commit comments

Comments
 (0)