Skip to content

Conversation

@zerone0x
Copy link
Contributor

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

@github-actions
Copy link
Contributor

The following comment was made by an LLM, it may be inaccurate:

Potential Duplicate Found

PR #7939: "fix: add error handling to RPC system to prevent crashes on session abort"
#7939

Why it's related: This PR addresses the same underlying issue of handling errors during session abort to prevent crashes. Both PRs target the scenario where a session abort races with in-flight requests, though PR #7939 focuses on the RPC system while PR #7959 (current) targets the TUI prompt component specifically.

@zerone0x zerone0x force-pushed the fix/abort-json-parse-crash branch from 88785d6 to a29bca8 Compare January 12, 2026 09:46
When aborting a session with double-escape, the abort races with the
in-flight prompt request. If the response is incomplete or empty, the
SDK's JSON parser throws "Unexpected end of JSON input". Adding .catch()
silences this expected error during abort, matching the pattern used
elsewhere for session.abort() calls.

Fixes anomalyco#7946

Co-Authored-By: Claude <noreply@anthropic.com>
@mrlubos
Copy link
Contributor

mrlubos commented Jan 13, 2026

@zerone0x this will be handled upstream, not sure if your change is still relevant after that hey-api/openapi-ts#3202

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.

Crash on double-escape abort: JSON parse error from prompt response

2 participants