-
Notifications
You must be signed in to change notification settings - Fork 14.6k
fix: unhandled promise rejection on session cancel bleeds stderr into TUI #19855
Copy link
Copy link
Open
Labels
coreAnything pertaining to core functionality of the application (opencode server stuff)Anything pertaining to core functionality of the application (opencode server stuff)
Description
Bug
When pressing Escape to cancel an in-progress LLM generation in the TUI, an unhandled promise rejection stack trace writes to stderr and corrupts the terminal display.
Root Cause
The abort HTTP endpoint at session.ts:384 calls SessionPrompt.cancel() without await or .catch(). cancel() internally calls cb.reject(new Error("Session cancelled")) to reject pending promises. Since the endpoint returns c.json(true) before cancel() completes, the rejection is unhandled and Bun writes the stack trace to stderr.
Two additional fire-and-forget calls in prompt/index.tsx also lack .catch():
sdk.client.session.abort()(line 262)sdk.client.session.command()(line 654)
Reproduction
- Start a session in the TUI
- Send a message that triggers LLM generation
- Press Escape twice during generation
- Observe stack trace text bleeding over the TUI rendering
Fix
See sjawhar#1
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
coreAnything pertaining to core functionality of the application (opencode server stuff)Anything pertaining to core functionality of the application (opencode server stuff)