fix(fetch): emit final streamJSON line without trailing newline#12604
fix(fetch): emit final streamJSON line without trailing newline#12604devYRPauli wants to merge 1 commit into
Conversation
💡 Codex ReviewWhen an overloaded/529 error is thrown after the assistant has already streamed some content, https://github.com/continuedev/continue/blob/c47c5d2269b2f8a3384b65b2704a5e23380a3e37/docs-site/app/[[...slug]]/page.tsx#L69-L71 For internal redirects like ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
streamJSON()only parsed JSON objects when a newline arrived. If a JSON-lines response ended with a valid final object and no trailing\n, that object stayed in the buffer and was silently dropped when the stream ended.streamSse()already drains its leftover buffer afterstreamResponse()completes; this applies the same EOF handling tostreamJSON()and keeps malformed final JSON reporting the existingMalformed JSON sent from servererror shape.Proof:
npm test -- src/stream.test.tsfailed becausestreamJSON()yielded only[{ foo: "bar" }]and dropped the final{ baz: 42 }object.npm test -- src/stream.test.tspassed, 12/12.npm testpassed, 98/98.npm run buildpassed for@continuedev/fetch.Summary by cubic
Fixes
streamJSON()so it emits the final JSON object when a JSON-lines response ends without a trailing newline, preventing data loss. MatchesstreamSse()EOF behavior and keeps the same malformed JSON error.Malformed JSON sent from server: ...(unchanged error shape).Written for commit c47c5d2. Summary will update on new commits.