Skip to content

test(jetbrains): fix flaky worktree fork dedupe test - #13947

Merged
marius-kilocode merged 1 commit into
mainfrom
fix-flaky-jetbrains-tests
Sep 9, 2026
Merged

marius-kilocode merged 1 commit into
mainfrom
fix-flaky-jetbrains-tests

Conversation

@marius-kilocode

Copy link
Copy Markdown
Collaborator

What Problem This Solves

The JetBrains CI job flaked in WorktreeSessionEditorManagerTest > test a second fork of the same session is ignored while the first is in flight with expected:<1> but was:<0> at WorktreeSessionEditorManagerTest.kt:301.

Why This Change Was Made

The test called pump() after forkSession() and then asserted the first fork RPC had been recorded. pump() only flushes the EDT. FakeSessionRpcApi.fork records the call on the background dispatcher before awaiting forkGate, so under load the assertion could run before the coroutine was scheduled and see zero forks.

The fix waits for the in-flight RPC with the existing waitUntil helper before firing the duplicate, then flush() so an accidental second call would surface. This matches the established GhStatusCoordinatorTest.awaitCalls(1) pattern for the same "first RPC is in flight" check.

User Impact

None. Test-only change.

Evidence

  • Full ./gradlew :frontend:test from packages/kilo-jetbrains/: 3884 tests pass.
  • 10 consecutive stress runs of WorktreeSessionEditorManagerTest with cleanTest: all pass.
  • Forced reproduction with a widened race window in the fake RPC failed at line 301 with the old synchronization and passed with the fix.

The dedupe test asserted the first fork RPC was recorded after pump(),
but pump() only flushes the EDT. FakeSessionRpcApi.fork records the call
on the background dispatcher before awaiting forkGate, so the assertion
could run first and see no fork.

Wait for the in-flight RPC with waitUntil before firing the duplicate,
then flush() so an accidental second call would surface.
@marius-kilocode
marius-kilocode merged commit 298f9a2 into main Sep 9, 2026
22 of 23 checks passed
@marius-kilocode
marius-kilocode deleted the fix-flaky-jetbrains-tests branch September 9, 2026 07:52
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.

2 participants