npm / eventsource-parser
eventsource-parser
What changed in eventsource-parser 3 to 4, from its official release notes, upgrade guides and advisories. Sources checked 2026-10-17.
4 breaking2 new APIs and options2 performance1 behavior and defaults4 fixes and other
See which of these apply to your code, ranked, in your agent:
npx @unstale/cli initeventsource-parser 49 changes
Breaking changes 4
The CommonJS build and its
mainfield andrequireexport conditions are removed; Node 22.12 and above supportsrequire(esm)transparently.The package now requires Node.js >=22.12; Node.js 18 and 20 are no longer supported or guaranteed.
Invalid lines are discarded as soon as they cannot become a valid SSE field;
onErroris not called and noline,field, orvalueis retained.The root
stream.jsfile is removed; importeventsource-parser/streaminstead and ensure your bundler resolves theexportsfield.
New APIs and options 1
Adds a callback that reports ID fields when an event block ends, including blocks without data.
Behavior and default changes 1
Partial comment lines are buffered only when an
onCommentcallback is configured; otherwise, they are discarded.
Fixes and other changes 3
Buffer limits are enforced while processing a chunk.
Handles leading byte-order marks across empty input chunks and split raw UTF-8 BOM chunks so the first event is not dropped.
A leading byte order mark is stripped whether it arrives as decoded
U+FEFFor as the raw three-byte sequence.
eventsource-parser 34 changes
New APIs and options 1
Adds the maxBufferSize option.
Performance 2
Avoids O(N²) behavior when a single SSE event spans many chunks.
Parsing is ~3.75x faster via inline fast-paths and single-pass line processing.
Fixes and other changes 1
An id: line containing a NULL character no longer wipes the buffered event id.