opencode icon indicating copy to clipboard operation
opencode copied to clipboard

UI overlay breaks when Vertex AI returns truncated JSON responses

Open Skeptomenos opened this issue 1 day ago • 7 comments

Description

When using OpenCode heavily with Vertex AI Flash models, the UI breaks with an error overlay showing:

SyntaxError: Unexpected end of JSON input
at <parse> (native)
at json (unknown)
at <anonymous> (../sdk/js/src/v2/gen/client/client.gen.ts:167:33)

Environment

  • Provider: Vertex AI (Flash models)
  • Usage pattern: Heavy/concurrent usage

Root Cause Analysis

The error occurs at client.gen.ts:167 when response.json() is called on a truncated response body. This happens when:

  • Network connection drops mid-response
  • Vertex AI times out or rate-limits under load
  • Multiple concurrent requests strain the connection

While error handling exists in the SDK (lines 169-198), the error still surfaces to the UI and breaks the interface with an overlay.

Expected Behavior

Transient JSON parse errors from provider responses should be caught and retried gracefully without breaking the UI overlay.

Actual Behavior

Error overlay appears, blocking the UI and requiring manual dismissal or restart.

Screenshot

Error Screenshot

Suggested Fix

Consider catching SyntaxError specifically in the streaming/response handling layer and treating truncated JSON as a retryable error rather than surfacing it to the UI.

Skeptomenos avatar Jan 12 '26 11:01 Skeptomenos