Skip to content

fix: support CR line endings in SSE - #276

Open
KennyMcSimpson wants to merge 1 commit into
MiniMax-AI:mainfrom
KennyMcSimpson:fix/sse-cr-line-endings
Open

KennyMcSimpson wants to merge 1 commit into
MiniMax-AI:mainfrom
KennyMcSimpson:fix/sse-cr-line-endings

Conversation

@KennyMcSimpson

@KennyMcSimpson KennyMcSimpson commented Oct 5, 2026 •

Copy link
Copy Markdown

Summary

parseSSE splits only on LF. With bare CR line endings, two events such as data: first\r\rdata: second\r\r become one malformed data value instead of two events. SSE permits CR, LF and CRLF as line endings.

Handle all three forms, including CRLF split across network chunks. A CR completes the line immediately, so a finished event is delivered while the stream remains open. Existing field parsing and final-event flushing are preserved.

Tests

  • Add coverage at every byte boundary for CR, LF and CRLF, including empty chunks and fragmented UTF-8.
  • Check mixed endings with byte-by-byte delivery and dispatch before EOF.
  • bun test — 597 passed; bun test test/client/stream.test.ts — 19 passed.
  • bun run typecheck, bun run lint and bun run build pass. Lint reports one existing warning in test/sdk/speech.test.ts.
  • The CI compile/version smoke check and git diff --check pass.

Tested with Bun 1.4.2. Three new regression tests fail before the fix.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant