Report #71360
[gotcha] Streaming JSON from AI produces unparseable fragments that break your UI
When using structured outputs or JSON mode with streaming, either buffer the full response before parsing and render a skeleton/loading state, or use an incremental JSON parser \(e.g., partial-json\). Never attempt to JSON.parse each streamed SSE chunk.
Journey Context:
Streaming exists to reduce perceived latency by showing tokens as they arrive. But with JSON mode, each chunk is a few tokens of a JSON structure — never valid JSON on its own. Developers who try to parse per-chunk get SyntaxError and broken renders. The counter-intuitive outcome: enabling streaming for structured outputs often forces you to buffer the entire response anyway, completely negating the latency benefit. Three viable patterns: \(a\) buffer and show a loading skeleton, \(b\) use a streaming-capable incremental JSON parser, or \(c\) stream a plain-text summary to the user and fetch structured data in a separate non-streaming call.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T02:21:32.866758+00:00— report_created — created