Skip to content

fix(http): strip SSE BOM only at stream start - #341

Merged
benbrandt merged 1 commit into
agentclientprotocol:mainfrom
vathuluri:fix/sse-stream-bom
Nov 13, 2026
Merged

benbrandt merged 1 commit into
agentclientprotocol:mainfrom
vathuluri:fix/sse-stream-bom

Conversation

@vathuluri

Copy link
Copy Markdown
Contributor

Problem and change

parseSseStream() currently strips a UTF-8 BOM from every line. SSE decoding strips only one leading BOM from the whole stream (WHATWG SSE interpretation). Later U+FEFF characters are part of field names, which must be compared literally.

This can change delivered ACP messages: a BOM-only line inside a multiline JSON event becomes an empty line, prematurely dispatching and dropping the two JSON fragments. A later BOM-prefixed data: field is also incorrectly treated as a normal data field.

Track the first line and strip a BOM only there. Add four cases covering a leading BOM split byte by byte, a later BOM-prefixed field, a BOM-only line within multiline data, and a BOM after an initial empty line. Three cases fail on the original implementation; the leading-BOM case guards existing support.

This intentionally corrects the per-line BOM behavior preserved during #259; it does not change the protocol or public API.

Validation

Node.js 24.15.0 on Windows:

  • npm test: 640 tests passed across 23 files.
  • npm run generate:check, npm run typecheck, npm run lint, and npm run format:check: passed.
  • node node_modules/typescript/bin/tsc --project tsconfig.build.json and npm run package:check: passed. The direct compiler command was used because the build script's rm cleanup is unavailable in the Windows shell; the checkout had no previous build output.
  • npm run docs:ts:verify and git diff --check: passed.
  • Checkout line endings were normalized locally to LF for the generator/formatter checks; only the two intended SSE files are included.
  • The typos executable is not installed, so spellcheck was not run locally.

AI-assisted investigation, implementation, and tests; all stated checks were run locally using synthetic streams with no external model API calls.

@benbrandt
benbrandt enabled auto-merge (squash) November 13, 2026 08:46
@benbrandt
benbrandt merged commit 8e0cc0e into agentclientprotocol:main Nov 13, 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