Repository navigation
fix(tests): wait for the collector lifecycle subscription before the close-push test - #1865
Conversation
…e close-push test "pushes session-changed when POST /api/workspace/close answers" timed out under load and passed on rerun: "session-changed after create not received within 5000ms". The test waits for the creation's session-changed (so that it is not taken for the close's), and that frame comes from the status collector, debounced, once herdr's lifecycle event for the new workspace reaches it. It could be lost two ways: - The test created the workspace before connecting its WebSocket, so on a busy PC the frame could be broadcast before that socket subscribed. It now connects first. - The server had just started: nothing waited for the collector's lifecycle subscription, and a workspace created before it was live was never heard of (1 in 30 runs of the test alone, even connected first). The collector now says when that subscription is live (structureReady, on its first start or on a reopened one's), the server's statusReady, which contract tests already await, waits for it too, and api.contract.test.ts awaits statusReady before its tests. Deliberate reproduction: main's order with a 1.5 s gap between create and connect fails with that message. With both changes, 60 runs of the test alone on an isolated herdr: 0 failures (30 before the readiness change: 1).
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 22 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
CodeRabbit's review was rate-limited ("Review limit reached"), so no CodeRabbit review ran on this PR. The reviews below stand in for it. omo-native-code-reviewer (both versions): APPROVE, no blockers. Low notes: |
|
Merge pass review-work report. Overall: PASSED.
QA
Gate
All required checks are green and no review thread is open. CodeRabbit did not review this PR (rate-limited or skipped). The reviews above stand in for it. |
What failed
server/api.contract.test.ts› "pushes session-changed when POST /api/workspace/close answers, not after the collector's debounce" timed out under load and passed on rerun (seen on the pane-alert-mute lane):session-changed after create not received within 5000ms. The test waits for the creation'ssession-changedfirst, so that it is not taken for the close's, and that frame comes from the status collector, debounced, once herdr's lifecycle event for the new workspace reaches it.Root causes (two)
statusReadywas onlycollector.ready, which with no panes resolves without any subscription live, so a workspace created right afterbeforeAllcould be created before the subscription that hears it. With only the first change, 1 of 30 runs still failed this way (only the snapshot frame arrived).Fix
StatusCollector.structureReadyresolves when the lifecycle subscription is live (its first start, or a reopened one's).createServer'sstatusReady, which contract tests already await and nothing in production awaits, now waits for it too.api.contract.test.tsawaitsstatusReadyinbeforeAll.Proof
bun run check run): 0 failures (30 runs with only the first change: 1 failure).collector.test.tscase:structureReadystays pending until the lifecycle subscription starts, also when only a reopened one starts; it fails without the collector change.bun run check fast: passed (6387 pass, 0 fail). Typecheck clean.Noted, not changed: a
session-changedfrom elsewhere arriving during the close request could still satisfy the close wait (a false pass, not a flake; it existed before).