Repository navigation
fix(tui): keep mini waiting when session.wait loses its transport - #57062
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Looks sound. The new test fails on dev with the same session.wait → waitForIdle Transport error as #50135 and passes with this change. bun test test/mini (414 pass) and typecheck in packages/tui are clean. I tried an end-to-end check with mini --server and BUN_CONFIG_HTTP_IDLE_TIMEOUT=2, but couldn't trigger Bun's deadline on either branch, so that part relies on your manual run.
The retry is narrow: only ClientError with reason Transport while not aborted. Each retry waits for the event stream to reconnect and picks up the current client, so it neither spins nor sticks to a stale client after a reconnect.
Public API is unchanged; the change is internal to mini.
Related: #54974
This was referenced Oct 20, 2026
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.
Issue for this PR
Closes #50135
Type of change
What does this PR do?
opencode miniexits with status 1 andClientError: Transport: The operation timed out.(stack throughwaitForIdle) when a turn runs longer than Bun's built-in fetch deadline. Latest report: https://x.com/tasarren/status/2112143353017958749 (v2.0.30,mini --standalone).How it happens:
session.wait, a long poll that sends no bytes until the session goes idle.fetch. Bun ends such a request after its default deadline (about 360s on Bun 1.4.2), so the request fails while the session keeps running.runTurnWait, that error is caught and shown as an error row. But when a prompt was admitted mid-turn (a follow-up typed while busy, or a message from another agent), the queue callssettle→waitForIdle. Nothing catches the error there, sorunPromptQueuerejects and the process exits. With--standalone, the private server and the running turn exit along with it.The fix:
settleSessionnow treats a transport failure ofsession.waitas the end of that one request, not of the session. It waits for the event stream to be connected again, then callssession.waitagain on the current client (which may have been replaced by a reconnect). Aborts and other errors still throw as before. This also stops the bogus "Transport: The operation timed out." row on long turns.#50248 separately removes Bun's deadline from mini's client (
timeout: false, the same asrun). The two PRs complement each other: that one avoids the unneeded timeout, and this one keeps mini alive whenever the wait connection drops for any reason (timeout, a reconnect, or a server restart).How did you verify your code works?
packages/tui/test/mini/stream-v2.transport.test.ts: the firstsession.waitrejects withClientError("Transport", TimeoutError).waitForIdlewaits again and reconciles. It fails ondevand passes with this change (--rerun-each 10).bun test test/miniinpackages/tui(414 pass) andbun run checkboth pass.mini --standalonefrom source against a fake OpenAI-compatible provider that holds each completion for 40s, withBUN_CONFIG_HTTP_IDLE_TIMEOUT=2to shorten Bun's deadline to about 8s. I sent a prompt, then a follow-up while it was busy.dev: a "Transport: The operation timed out." row appears, then mini exits with status 1 with the same stack as the report (session.wait→waitForIdle→runtime.queue).Screenshots / recordings
Not a visual change. The before/after was checked in a terminal as described above.
Checklist
— from 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊
Added by the opencode bot (AI-generated).
Related: #54974