test(cli): remove session cancellation timing races - #11299
Merged
Conversation
Co-authored-by: kiloconnect[bot] <240665456+kiloconnect[bot]@users.noreply.github.com>
Contributor
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Files Reviewed (2 files)
Previous Review Summary (commit 670f2fa)Current summary above is authoritative. Previous snapshots are kept for context only. Previous review (commit 670f2fa)Status: No Issues Found | Recommendation: Merge Files Reviewed (2 files)
Other Observations (not in diff)Several remaining Reviewed by deepseek-v4-pro-20260423 · 371,954 tokens Review guidance: REVIEW.md from base branch |
Convert the remaining `Effect.sleep(50)` synchronization hacks in
`prompt.test.ts` to either `Effect.yieldNow` or `waitFor` against
`SessionStatus`, mirroring the pattern already used elsewhere in the
file. Same motivation as the previous commit: stop making correctness
depend on how quickly CI schedules fibers.
- "concurrent loop callers all receive same error result": yieldNow
before resolving the gate, so the queued caller joins the run on a
scheduler turn instead of a 50ms window.
- "loop waits while shell runs ..." / "shell completion resumes
queued loop callers": yieldNow before asserting `llm.calls === 0`
while the shell is still running. The shell is already gated on
`waitFor("shell busy", ...)`.
- "cancel interrupts loop queued behind shell": waitFor shell busy
before forking the loop, then yieldNow before cancelling.
- "shell rejects when another shell is already running": waitFor
shell busy before issuing the second shell call.
The `Effect.sleep(20)` at line 93 is the poll interval inside the
`waitFor` helper itself and is left unchanged.
markijbema
enabled auto-merge
June 16, 2026 14:09
chrarnoldus
approved these changes
Jun 16, 2026
t7tran
pushed a commit
to t7tran/kilocode
that referenced
this pull request
Aug 14, 2026
…n-cancellation-tests test(cli): remove session cancellation timing races
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.
Why
The Windows unit job in PR #10388 failed in two session cancellation tests even though the corresponding Linux job passed. Looking across recent failed workflows showed both failures were intermittent and strongly correlated with loaded Windows runners:
stops quickly when aborted during retry backofffailed when interrupt cleanup exceeded an internal 2-second wall-clock deadline.cancel with queued callers resolves all cleanlypreviously failed at its whole-test timeout and still used a fixed 50 ms sleep to assume the second caller had joined the active run.Neither deadline is part of the behavior these tests need to prove. They make correctness depend on how quickly CI schedules Effect fibers and finalizers. Workflow reruns frequently pass without code changes, while the underlying cancellation assertions remain stable.
What changed
Effect.sleep(50)withEffect.yieldNowbefore cancelling queued prompt callers. This gives the newly forked caller a scheduler turn without requiring it to complete within an arbitrary real-time window.Why this preserves coverage
The behavioral assertions are unchanged:
This removes timing assumptions rather than weakening the expected cancellation semantics. The lower-level runner suite also covers queued cancellation using observable runner state, so the prompt integration test remains focused on end-to-end behavior.