Repository navigation
fix(streaming): handle mixed SSE line endings - #2309
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8563f8ab8c
ℹ️ 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".
HAYDEN-OAI
left a comment
There was a problem hiding this comment.
Approved after reviewing the coordinated SSE scanner and incremental line-decoder changes, confirming the eight valid delimiter combinations across fragmented open streams, and verifying the updated branch against current main.
|
Thanks for the contribution and for spotting the gap in our SSE line-ending handling! We updated the implementation to cover fragmented mixed delimiters and immediate carriage-return delivery, and your PR is now approved with auto-merge enabled pending the required workflow approvals and checks. |
Changes being requested
Recognize SSE event delimiters formed by consecutive
LF, standaloneCR, orCRLFline endings, including valid mixed combinations. ACRimmediately followed byLFis oneCRLFline ending, not two.The incremental line decoder now emits
CR-terminated lines immediately and remembers whether to consume one optional followingLF. This preserves prompt event delivery when transport chunks splitCRLF, avoids phantom blank lines, and keeps the existing optimized SSE scan window unchanged.This changes only the handwritten streaming decoder and its focused regression coverage.
Why
LineDecoderalready recognized all three SSE line-ending forms, butfindDoubleNewlineIndex()recognized onlyLF+LF,CR+CR, andCRLF+CRLF. A valid mixed-ending stream such asdata: first\n\r\ncould therefore remain buffered on an open connection until another recognized delimiter or EOF.Standalone-
CRevent delimiters could also be delayed because the decoder previously waited for another byte before emitting the completed line. Emitting immediately and suppressing a following optionalLFfixes both standalone-CRand fragmented mixed-ending delivery.Verification
pnpm test:unit: 66 files and 1,774 tests passed after updating the branch with the latestmain.pnpm lintpassed.pnpm exec tsc --noEmit --pretty falsepassed.pnpm buildpassed for CommonJS and ESM, including package import smoke checks.CRLF, phantom-event prevention, mixed multiline events, and incomplete versus complete records at EOF.Vitest can rewrite unrelated legacy Jest snapshot headers locally; those mechanical changes are not included in this PR.