Skip to content

fix(fetch): emit final streamJSON line without trailing newline#12604

Open
devYRPauli wants to merge 1 commit into
continuedev:mainfrom
devYRPauli:fix/stream-json-final-buffer
Open

fix(fetch): emit final streamJSON line without trailing newline#12604
devYRPauli wants to merge 1 commit into
continuedev:mainfrom
devYRPauli:fix/stream-json-final-buffer

Conversation

@devYRPauli

@devYRPauli devYRPauli commented Jun 11, 2026

Copy link
Copy Markdown

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 after streamResponse() completes; this applies the same EOF handling to streamJSON() and keeps malformed final JSON reporting the existing Malformed JSON sent from server error shape.

Proof:

  • RED: npm test -- src/stream.test.ts failed because streamJSON() yielded only [{ foo: "bar" }] and dropped the final { baz: 42 } object.
  • GREEN: npm test -- src/stream.test.ts passed, 12/12.
  • Full package validation: npm test passed, 98/98.
  • Build: npm run build passed 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. Matches streamSse() EOF behavior and keeps the same malformed JSON error.

  • Bug Fixes
    • Drain and parse the remaining buffer at stream end; yield the last object if valid.
    • If invalid, throw Malformed JSON sent from server: ... (unchanged error shape).
    • Added a unit test for JSON-lines without a trailing newline.

Written for commit c47c5d2. Summary will update on new commits.

Review in cubic

@devYRPauli devYRPauli requested a review from a team as a code owner June 11, 2026 14:23
@devYRPauli devYRPauli requested review from sestinj and removed request for a team June 11, 2026 14:23
@dosubot dosubot Bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label Jun 11, 2026
@chatgpt-codex-connector

Copy link
Copy Markdown

💡 Codex Review


P2 Badge Avoid replaying the entire chat thunk on retry

When an overloaded/529 error is thrown after the assistant has already streamed some content, cancelStream() preserves that partial assistant message, and the next loop iteration re-runs the caller's whole runStream() closure. For normal chat this recomputes inputIndex from the now-longer history and dispatches submitEditorAndInitAtIndex again, creating a second user message and sending the same prompt as a new turn rather than retrying the failed assistant response.


https://github.com/continuedev/continue/blob/c47c5d2269b2f8a3384b65b2704a5e23380a3e37/docs-site/app/[[...slug]]/page.tsx#L69-L71
P2 Badge Keep internal docs redirects on app-local paths

For internal redirects like /cli/overview -> /cli/quickstart, this generates /docs/cli/quickstart, but the new docs app's catch-all route resolves slugs directly against DOCS_DIR, so /docs/cli/quickstart looks for docs/docs/cli/quickstart.mdx and lands on the not-found page. Other docs links strip the /docs prefix via resolveHref, so redirects should do the same instead of adding it.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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".

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

Re-trigger cubic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

1 participant