Skip to content

fix(http): handle CR line endings in SSE streams - #306

Merged
benbrandt merged 2 commits into
agentclientprotocol:mainfrom
Oscar-Williams:fix/sse-carriage-return-framing
Oct 23, 2026
Merged

benbrandt merged 2 commits into
agentclientprotocol:mainfrom
Oscar-Williams:fix/sse-carriage-return-framing

Conversation

@Oscar-Williams

@Oscar-Williams Oscar-Williams commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Summary

SSE permits CR, LF and CRLF line endings (specification). The parser currently splits only at LF, so a response framed with CR can wait indefinitely or be combined with the next event.

Recognize CR immediately and consume an optional following LF across chunks using the existing bounded line buffer.

Validation

  • npm test: 490 passed.
  • Local regression cases: 5 failures on main; all 23 cases pass with the fix. Cases cover mixed endings, UTF-8, split CRLF, dispatch before EOF, limits and cancellation.
  • A real HTTP stream delivers a CR event before closing; 500 framing cases match an independent reference.
  • Generation, formatting, lint, typecheck, build, package contents, TypeDoc and typos checks passed on Windows with Node 24.

Additional regression cases remain local, following the repository's instructions on tests and documentation.

Oscar-Williams and others added 2 commits October 23, 2026 01:35
Move CR handling into an opt-in LineBuffer mode so CRLF lines within a
chunk stay zero-copy and each byte is scanned once. Add regression tests
for bare CR, mixed, and split CRLF line endings.
@benbrandt
benbrandt enabled auto-merge (squash) October 23, 2026 11:00
@benbrandt
benbrandt merged commit fd86335 into agentclientprotocol:main Oct 23, 2026
2 checks passed
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.

2 participants