Repository navigation
test(pty-connection): drain async confirm reads between tests to fix flaky CI - #9260
Merged
Merged
Conversation
The connectPanePty suite intermittently fails in CI on `clearAgentLaunchConfig` call-count assertions (e.g. expected exactly once, received 5 with pane keys belonging to other tests). Root cause is cross-test async leakage: pane foreground-agent trackers kick off `confirmForegroundProcess` reads whose continuations settle on the microtask queue, not on fake timers. A test that ends with one still in flight leaks it into the next test, where it resolves against that test's fresh store mock and calls clearAgentLaunchConfig with the prior test's pane key. Drain pending microtasks in afterEach (before tearing down fake timers, while the test still owns its store mock) so each test absorbs its own async fallout. No behavior change; full suite stays green (446/446). Note: this is a CI-timing flake not reproducible locally in isolation (ordered runs pass repeatedly, incl. under GC pressure); the fix targets the confirmed leak mechanism and removes the timing dependence.
Contributor
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughUpdated the PTY connection test suite’s 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
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 |
7 tasks done
6 tasks
enrick-dev
pushed a commit
to enrick-dev/orca
that referenced
this pull request
Oct 15, 2026
…ai#9260) The connectPanePty suite intermittently fails in CI on `clearAgentLaunchConfig` call-count assertions (e.g. expected exactly once, received 5 with pane keys belonging to other tests). Root cause is cross-test async leakage: pane foreground-agent trackers kick off `confirmForegroundProcess` reads whose continuations settle on the microtask queue, not on fake timers. A test that ends with one still in flight leaks it into the next test, where it resolves against that test's fresh store mock and calls clearAgentLaunchConfig with the prior test's pane key. Drain pending microtasks in afterEach (before tearing down fake timers, while the test still owns its store mock) so each test absorbs its own async fallout. No behavior change; full suite stays green (446/446). Note: this is a CI-timing flake not reproducible locally in isolation (ordered runs pass repeatedly, incl. under GC pressure); the fix targets the confirmed leak mechanism and removes the timing dependence.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The
verifyjob intermittently fails in CI on theconnectPanePtysuite(
src/renderer/src/components/terminal-pane/pty-connection.test.ts) with aclearAgentLaunchConfigcall-count assertion, e.g.:(This is what failed the
verifycheck on #9254.)Root cause
Cross-test async leakage. Pane foreground-agent trackers
(
createPaneForegroundAgentTracker) kick offconfirmForegroundProcessreadswhose continuations settle on the microtask queue, not on fake timers. A
test that ends with one still in flight leaks it into the next test, where it
resolves against that test's freshly-reset store mock and calls
clearAgentLaunchConfigwith the prior test's pane key. Because the storemock's
getState()always returns the current test'smockStoreState, thestale continuation pollutes whichever test happens to be running when it
settles — hence the foreign
2222…(LEAF_2) keys in a test that only uses1111…(LEAF_1).Fix
Drain pending microtasks in
afterEach(via the existingflushAsyncTickshelper) before tearing down fake timers, while the test still owns its
store mock. Each test then absorbs its own async fallout instead of leaking it
forward. Behavior-only test-harness change; no product code touched.
Validation
--max-old-space-size=700GC pressure).Honest caveat on reproducibility
This is a CI-timing flake: I could not reproduce it locally in isolation —
ordered runs pass repeatedly, and the delicate inter-test microtask timing that
triggers it only shows up under the full-suite CI environment. The fix targets
the one mechanism that can produce the exact error signature (a leaked async
continuation calling a store mutator with another test's pane key) and removes
the timing dependence. Nearly all reads in the affected path run under fake
timers, so a real-timer variant of the same leak is not the vector here.
Separately, I noticed running this file with
--sequence.shuffleOOMs (runawayallocation) — a distinct, pre-existing issue unrelated to the ordered CI
failure and out of scope for this PR; noting it for follow-up.