Repository navigation
test(take-over): hold a failing attach's last line until its exit on a busy runner - #2373
Conversation
…a busy runner The ordinary-failure recovery test used the 100 ms default attach hold. Its stand-in prints "terminal attach taken over" and only then exits, so on a busy runner the hold could end first: the attempt counted as attached, the bridge sent attach-resumed, and the test's wait for the recovery returned before the third attempt started (starts() 2 instead of 3). Hold for 2 s, as long as the bridge waits for a refusal's late exit, so the exit always comes first.
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Attach hold timing server/take-over.contract.test.ts, changelog.d/integration-flake-take-over-recovery.md |
The recovery test sets the fixture’s attach hold duration to 2,000 ms and documents the expected timing around the failing attempt’s final output and exit. The changelog records this test change. |
Priority:
Estimated code review effort: 2 (Simple) | ~8 minutes
Change: Other
Possibly related issues
- Issue 2225 describes broader determinism concerns around attach-delivery acknowledgement and server hold margins. This change addresses a related timing case in the recovery test, but does not implement those broader concerns.
Possibly related PRs
- devswha/ovis#1783: This PR also changes attach-EOF recovery behavior and updates the same take-over contract test.
Suggested reviewers: wouldu-pres
Merge Risk: 
Minimal · up to 7597f
-
The test timing adjustment is scoped to the test fixture, with no actionable merge-blocking risk identified.
Pre-merge checks: 
5
-
Full details: Description check
-
Explanation
The description explains the failure, cause, timing fix, test-only scope, and validation results. It includes the required Change information and provides Validation information under Proof and Local checks, although it does not use the exact Validation heading.
Full details: Docstring Coverage
-
Explanation
No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 0 functions across 1 files. (1 skipped: 1 unsupported.)
-
Finishing Touches
-
📝 Generate docstrings
-
- Commit to this branch
- Create a new PR
🧪 Generate unit tests (beta)
-
- Commit to this branch
- Create a new PR
-
- 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.
Comment @coderabbitai help to get the list of available commands.
|
Merging 7597f65. Test-only: in server/take-over.contract.test.ts the failing attempt in the ordinary-failure recovery case now holds its last line well past the fixture's exit, so a busy runner cannot read that line as an attach before the exit arrives. Diff read by the merge pass; no CodeRabbit review needed. |
…s exit too (#2396) This is the second commit of #2373, which merged at its first commit (7597f65) before this one reached the branch. It was reviewed there; it is cherry-picked onto current main here. Found by the flake-hunt lane on #2380's Integration run (job 123700768179): `server/take-over.contract.test.ts` "consumes a click when the running ordinary retry succeeds, before later displacement" failed at `:89`, where `pty-data` contained "terminal attach taken over". ## Cause (test flake) This is the same cause as #2373: the 100 ms default attach hold. Displaced by another client's `--takeover`, herdr prints its teardown and "terminal attach taken over", then exits. The bridge keeps an attach's last line in the output tail for the hold (`tailTimer` in `server/core/terminal-process.ts`) and drops it at a displaced exit (`flushTail(displaced)`). An exit more than 100 ms after the line, as on a busy runner, let the line reach clients first. ## Change A 2 s hold for this test too, as #2373 gave the ordinary-failure test. The changelog fragment from #2373 now names both tests. ## Proof - **Fail-first:** with the fixture's `real` wrapper exiting 300 ms after herdr (scratch), the old test failed 3/3 with CI's `not.toContain` and the new one passed 3/3. - **Whole file:** passed 9/9 three times. On current main with this cherry-pick it passed 9/9 again (`bun run check run bun test server/take-over.contract.test.ts`). - **Local checks:** `bun run check fast` ok. Test-only. ## Reviews - **omo-native-code-reviewer:** APPROVE, CLEAR (on #2373's branch). It confirmed the tail-hold mechanism and that the test still asserts the consumed click, the retry without `--takeover`, and no taken-over text. - LOW product note, not fixed here: production also holds the tail 100 ms, so on a loaded machine, when another client takes over, a user can briefly see herdr's teardown line until the next attach redraws. A longer tail hold for displacement would remove it. - Test-only, so no Codex review (notes/pr-policy.md).
Found by the flake-hunt lane: Integration failed and passed on a rerun with no code change on run 40867226519 (feat/terminal-open-bare-filename, 2026-10-29) and run 40646297534 (ci/self-hosted-runner-cache, 2026-10-28), both at
server/take-over.contract.test.ts:220withexpect(f.starts()).toHaveLength(3),Received length: 2.Cause (test flake)
"recovers an ordinary failure without turning a click during its terminal lookup into takeover" ran with the default attach hold,
ATTACH_HOLD_MS= 100 ms (server/core/terminal-process.ts:34). Its second attempt's stand-in (scripts/fixtures/attach-sequence.mjs, stepfailed) printsterminal attach taken overand only then exits. On a busy runner the exit can reach the bridge more than 100 ms after the print. The hold then ends first, andtook()finds no refusal in that line, counts the attempt as attached, and broadcastsattach-resumedfor the pane that was held since the first attempt. The test's wait for "ordinary recovery attaches again" returns on that early frame, before the third attempt starts.Reproduced: with the stand-in's exit delayed by 300 ms after its last line (scratch change, not committed), the old test fails 5 of 5 with CI's
Expected length: 3/Received length: 2.Change
The test holds for 2 s, as long as the bridge waits for a refusal's late exit (
ATTACH_REFUSAL_EXIT_MS). That is far longer than the stand-in's exit, so the failing attempt always ends as an ordinary failure first. The sibling displacement test already passes a 5 s hold for the same reason. The recovered attach waits out the same hold before it resumes, well within the test's 10 s wait.Proof
dori heavy).bun run check fastok.Test-only.
Reviews
took()/ended(), and that with the long hold the test still checks no--takeoveron attempt 3, the "taken over" text inpty-data, and nopty-exit. LOW-1 (a 5 s hold left only about 4.5 s of headroom on the 10 s wait) was taken: the hold is now 2 s. LOW-2: a futurefailed/takenstep on the default hold would hit the same race. Both tests that use those steps now pass a long hold.Second commit: the displacement test (same cause)
Found on #2380's Integration run (job 123700768179): "consumes a click when the running ordinary retry succeeds, before later displacement" failed at
server/take-over.contract.test.ts:89, wherepty-datacontained "terminal attach taken over".Cause: the same 100 ms default hold. Displaced by another client's
--takeover, herdr prints its teardown and "terminal attach taken over", then exits. The bridge keeps an attach's last line in the output tail for the hold (tailTimerinserver/core/terminal-process.ts) and drops it at a displaced exit (flushTail(displaced)). When the exit came more than 100 ms after the line, the line reached the clients first.Change: a 2 s hold for this test too.
Proof:
realwrapper exiting 300 ms after herdr (scratch), the old test failed 3/3 with CI'snot.toContainand the new one passed 3/3.bun run check fastok.Review (omo-native-code-reviewer): APPROVE, CLEAR. The fragment wording LOW was taken. One LOW product note is not fixed here: production also holds the tail 100 ms, so on a loaded machine, when another client takes over, a user can briefly see herdr's teardown line ("herdr: server shut down: terminal attach taken over") until the next attach redraws. It is cosmetic, brief, and less likely than in the test, which adds a node wrapper. A longer tail hold for displacement would remove it.