unstale

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 init

@unstale/cli 0.1.1 on npm

eventsource-parser 49 changes

Breaking changes 4

  • The CommonJS build and its main field and require export conditions are removed; Node 22.12 and above supports require(esm) transparently.

    4.0.0release notes

  • The package now requires Node.js >=22.12; Node.js 18 and 20 are no longer supported or guaranteed.

    4.0.0release notes

  • Invalid lines are discarded as soon as they cannot become a valid SSE field; onError is not called and no line, field, or value is retained.

    4.0.0release notes

  • The root stream.js file is removed; import eventsource-parser/stream instead and ensure your bundler resolves the exports field.

    4.0.0release notes

New APIs and options 1

  • Adds a callback that reports ID fields when an event block ends, including blocks without data.

    4.1.0release notes

Behavior and default changes 1

  • Partial comment lines are buffered only when an onComment callback is configured; otherwise, they are discarded.

    4.0.0release notes

Fixes and other changes 3

  • Buffer limits are enforced while processing a chunk.

    4.1.2release notes

  • Handles leading byte-order marks across empty input chunks and split raw UTF-8 BOM chunks so the first event is not dropped.

    4.1.1release notes

  • A leading byte order mark is stripped whether it arrives as decoded U+FEFF or as the raw three-byte sequence.

    4.0.0release notes

eventsource-parser 34 changes

New APIs and options 1

Performance 2

  • Avoids O(N²) behavior when a single SSE event spans many chunks.

    3.0.8release notes

  • Parsing is ~3.75x faster via inline fast-paths and single-pass line processing.

    3.0.7release notes

Fixes and other changes 1

  • An id: line containing a NULL character no longer wipes the buffered event id.

    3.1.1release notes