Summary
parseOpenAiSseLine catches JSON.parse failures and silently returns {}. When a provider emits a truncated or corrupt data: chunk mid-stream (e.g. a network glitch), the chunk is dropped with no diagnostic. Combined with the missing body-consumption timeout in streaming requests, a broken connection can leave the user with a partial suggestion and no error at all.
Location
src/providers/sse.ts:77-99 (OpenAI parser), specifically the catch at :95-97
Code snippet
try {
const parsed = JSON.parse(payload) as { ... };
...
return result;
} catch {
// Skip malformed JSON chunks
}
return {};
Suggested fix
Distinguish "not a data line" (fine to ignore) from "line starts with data: but payload is not valid JSON" (a real protocol anomaly). For the latter, surface a descriptive error to the caller (or warn) rather than continuing silently — e.g. track consecutive malformed chunks and fail the stream after a threshold.
Impact
- Silent partial/missing streamed content with no diagnostic when a connection hiccups mid-stream.
- In combination with the streaming timeout gap,
--stream can terminate with incomplete output and the user has no signal anything went wrong.
Summary
parseOpenAiSseLinecatchesJSON.parsefailures and silently returns{}. When a provider emits a truncated or corruptdata:chunk mid-stream (e.g. a network glitch), the chunk is dropped with no diagnostic. Combined with the missing body-consumption timeout in streaming requests, a broken connection can leave the user with a partial suggestion and no error at all.Location
src/providers/sse.ts:77-99(OpenAI parser), specifically thecatchat:95-97Code snippet
Suggested fix
Distinguish "not a data line" (fine to ignore) from "line starts with
data:but payload is not valid JSON" (a real protocol anomaly). For the latter, surface a descriptive error to the caller (or warn) rather than continuing silently — e.g. track consecutive malformed chunks and fail the stream after a threshold.Impact
--streamcan terminate with incomplete output and the user has no signal anything went wrong.