Skip to content

fix(tests): wait for the collector lifecycle subscription before the close-push test - #1865

Merged
devswha merged 1 commit into
mainfrom
fix/close-push-test-subscribe-first
Oct 24, 2026
Merged

devswha merged 1 commit into
mainfrom
fix/close-push-test-subscribe-first

Conversation

@devswha

@devswha devswha commented Oct 24, 2026

Copy link
Copy Markdown
Owner

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's session-changed first, 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)

  1. The test created the workspace before it connected its WebSocket, so on a busy PC the frame could go out before the socket that connected afterwards had subscribed. Deliberate reproduction: main's order with a 1.5 s gap between create and connect fails with exactly that message.
  2. Nothing waited for the collector's lifecycle subscription after server start. statusReady was only collector.ready, which with no panes resolves without any subscription live, so a workspace created right after beforeAll could 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

  • The test connects its socket before creating the workspace.
  • StatusCollector.structureReady resolves when the lifecycle subscription is live (its first start, or a reopened one's). createServer's statusReady, which contract tests already await and nothing in production awaits, now waits for it too. api.contract.test.ts awaits statusReady in beforeAll.
  • Runtime behaviour of the server does not change: only a promise that tests await is added and gated.

Proof

  • 60 runs of the test alone on an isolated herdr (bun run check run): 0 failures (30 runs with only the first change: 1 failure).
  • New collector.test.ts case: structureReady stays 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.
  • Reviews: omo-native-code-reviewer (approve, no blockers) and Codex (Sol 6.1, no findings).

Noted, not changed: a session-changed from elsewhere arriving during the close request could still satisfy the close wait (a false pass, not a flake; it existed before).

…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).
@coderabbitai

coderabbitai Bot commented Oct 24, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You'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.

Check out review usage here.

View limit details

Limit details: You’ve used all 4 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration
Commits

Reviewing files that changed from the base of the PR and between 427f5d3 and 4198a17.

Files selected for processing: 4
  • server/api.contract.test.ts
  • server/collector.test.ts
  • server/collector.ts
  • server/index.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@devswha

devswha commented Oct 24, 2026

Copy link
Copy Markdown
Owner Author

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: statusReady now never resolves if herdr can never start the lifecycle subscription (nothing in production awaits it; scripts/omp-question-compat.ts and scripts/telemetry-regression.ts would wait without their own bound); a stray session-changed arriving during the close request could still satisfy the close wait (a false pass that existed before). Not changed here.
Codex (Sol 6.1, codex exec): no findings; both start paths resolve structureReady, and no other StatusCollector implementation is affected.

@devswha

devswha commented Oct 24, 2026

Copy link
Copy Markdown
Owner Author

Merge pass review-work report. Overall: PASSED.

Lane Verdict Confidence
Manual QA (artifacts kept) PASS -
Gate review (another model; programming + remove-ai-slops applied directly) APPROVE HIGH

QA

  • 68 collector and conventions tests pass, and the typecheck passes.
  • The close-push contract test passes 5 runs in a row on an isolated herdr.
  • git merge-tree is clean, and no other open maintainer PR touches these files.

Gate

  • Nothing in production awaits statusReady, so server start can't hang on the new structureReady.
  • structureReady resolves on the lifecycle subscription's first start or a successful reopen.
  • structureReady stays pending only if herdr refuses the subscription or the collector stops first. That matches its contract.
  • The test now connects its socket before it creates the workspace.
  • No unrelated production change.

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.

@devswha
devswha merged commit 3346b03 into main Oct 24, 2026
17 checks passed
@devswha
devswha deleted the fix/close-push-test-subscribe-first branch October 24, 2026 15:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant