Skip to content

fix(cli): make shell cancel race-safe with uninterruptible setup#8924

Closed
shssoichiro wants to merge 1 commit intoKilo-Org:mainfrom
shssoichiro:flaky-test-fix
Closed

fix(cli): make shell cancel race-safe with uninterruptible setup#8924
shssoichiro wants to merge 1 commit intoKilo-Org:mainfrom
shssoichiro:flaky-test-fix

Conversation

@shssoichiro
Copy link
Copy Markdown
Contributor

Shell cancel was flaky because the fiber could be interrupted before messages were persisted to the database, causing lastAssistant to throw "Impossible". Also, the finish cleanup only covered the spawn phase, leaving tool parts stuck in "running" state when the interrupt landed between setup and spawn.

Wrap setup in uninterruptibleMask and use acquireUseRelease to guarantee the finish release runs on every exit path, including immediate interrupts that arrive before the spawn phase starts.

How to Test

Run the following 3 tests, which are flaky in main, repeatedly in a loop:

cancel interrupts shell and resolves cleanly
cancel persists aborted shell result when shell ignores TERM
cancel interrupts loop queued behind shell

Expected behavior: 100% pass rate (observed on this branch)

Get in Touch

ExpedientFalcon on Discord

Shell cancel was flaky because the fiber could be interrupted before
messages were persisted to the database, causing lastAssistant to throw
"Impossible". Also, the finish cleanup only covered the spawn phase,
leaving tool parts stuck in "running" state when the interrupt landed
between setup and spawn.

Wrap setup in uninterruptibleMask and use acquireUseRelease to guarantee
the finish release runs on every exit path, including immediate interrupts
that arrive before the spawn phase starts.
@kilo-code-bot
Copy link
Copy Markdown
Contributor

kilo-code-bot Bot commented Apr 14, 2026

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (1 files)
  • packages/opencode/src/session/prompt.ts

Reviewed by gpt-5.4-20260305 · 435,893 tokens

@marius-kilocode
Copy link
Copy Markdown
Collaborator

Hi @shssoichiro thanks for the fix. But we are quite careful on any changes in this direction at the moment. We will take care of the test issues.

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