[PR #7959] fix(tui): handle JSON parse error on double-escape abort #12573

Open
opened 2026-02-16 18:17:28 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/7959

State: open
Merged: No


Summary

Fixes #7946

When aborting a session with double-escape (pressing Esc twice), the session.abort() call races with the in-flight session.prompt() request. If the server terminates the response mid-stream, the response body is incomplete or empty, causing the SDK's JSON parser to throw SyntaxError: Unexpected end of JSON input.

Changes

  • Added .catch(() => {}) to the session.abort() call in the TUI prompt component to silently ignore expected errors during abort

This matches the existing pattern used in routes/session/index.tsx:400 and app/src/pages/session.tsx:577 for the same scenario.

Test plan

  • Run bun run typecheck on the opencode package (passes)
  • Manual test: Start a task, press Esc twice to abort mid-work
  • Verify no crash occurs, session aborts cleanly

🤖 Generated with Claude Code

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/7959 **State:** open **Merged:** No --- ## Summary Fixes #7946 When aborting a session with double-escape (pressing Esc twice), the `session.abort()` call races with the in-flight `session.prompt()` request. If the server terminates the response mid-stream, the response body is incomplete or empty, causing the SDK's JSON parser to throw `SyntaxError: Unexpected end of JSON input`. ## Changes - Added `.catch(() => {})` to the `session.abort()` call in the TUI prompt component to silently ignore expected errors during abort This matches the existing pattern used in `routes/session/index.tsx:400` and `app/src/pages/session.tsx:577` for the same scenario. ## Test plan - [x] Run `bun run typecheck` on the opencode package (passes) - [ ] Manual test: Start a task, press Esc twice to abort mid-work - [ ] Verify no crash occurs, session aborts cleanly --- 🤖 Generated with Claude Code
yindo added the pull-request label 2026-02-16 18:17:28 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#12573