Repository navigation
fix(http): strip SSE BOM only at stream start - #341
Merged
Merged
Conversation
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.
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, andnpm run format:check: passed.node node_modules/typescript/bin/tsc --project tsconfig.build.jsonandnpm run package:check: passed. The direct compiler command was used because the build script'srmcleanup is unavailable in the Windows shell; the checkout had no previous build output.npm run docs:ts:verifyandgit diff --check: passed.typosexecutable 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.