Skip to content

fix: unhandled promise rejection on session cancel bleeds stderr into TUI #19855

@sjawhar

Description

@sjawhar

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

  1. Start a session in the TUI
  2. Send a message that triggers LLM generation
  3. Press Escape twice during generation
  4. Observe stack trace text bleeding over the TUI rendering

Fix

See sjawhar#1

Metadata

Metadata

Assignees

Labels

coreAnything pertaining to core functionality of the application (opencode server stuff)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions