fix(react): use NDJSON format for streaming to handle TCP chunk boundaries#3000
Merged
antoniosarosi merged 2 commits intocanaryfrom Jan 19, 2026
Merged
fix(react): use NDJSON format for streaming to handle TCP chunk boundaries#3000antoniosarosi merged 2 commits intocanaryfrom
antoniosarosi merged 2 commits intocanaryfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…aries React hooks streaming would get stuck on localhost because TCP doesn't preserve message boundaries - multiple JSON objects could arrive in one chunk or be split across chunks. The original code assumed each reader.read() returns exactly one complete JSON object. Changes: - Server-side (stream.ts): Add newline delimiter after each JSON message - Client-side (hooks.tsx.j2): Buffer chunks and split by newlines (NDJSON) - Add tests for chunk boundary handling NDJSON (Newline-Delimited JSON) is the standard format used by OpenAI, Anthropic, and other streaming APIs.
3e04fed to
eac8e50
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Changes
stream.ts): Add newline delimiter after each JSON messagehooks.tsx.j2): Buffer chunks and split by newlines for proper NDJSON parsingTest plan