unstale

npm / eventsource-parser

eventsource-parser

What changed in eventsource-parser 2 to 4, from its official release notes, upgrade guides and advisories. Sources checked 2026-11-30.

13 breaking4 new APIs and options3 performance1 behavior and defaults6 fixes and other

See which of these apply to your code, ranked, in your agent:

npx @unstale/cli init

@unstale/cli on npm

eventsource-parser 410 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

Performance 1

  • Avoids quadratic scanning of chunks containing many CR-terminated lines or a distant CR after LF-terminated lines.

    4.1.3release 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 315 changes

Breaking changes 8

  • This type was removed in favor of the ParserCallbacks interface.

    3.0.0release notes

  • Replaces the ParsedEvent type; the type attribute has been removed.

    3.0.0release notes

  • The parser no longer takes an onParse callback; it takes an object of callbacks instead.

    3.0.0release notes

  • A new callback receives the reconnect interval directly.

    3.0.0release notes

  • This type was removed in favor of providing separate callbacks for each event type.

    3.0.0release notes

  • The parser now takes an object of callbacks instead of an onParse callback, allowing separate callbacks for each event type.

    3.0.0release notes

  • This type was removed; provide the interval directly to the onRetry callback.

    3.0.0release notes

  • Retry fields are parsed only when they contain completely valid integers.

    3.0.0release notes

New APIs and options 3

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 2

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

    3.1.1release notes

  • Mixed CRLF and LF line endings are now handled correctly.

    3.0.0release notes

eventsource-parser 22 changes

Breaking changes 1

  • The minimum supported Node.js version is now v18.

    2.0.0release notes

Fixes and other changes 1

  • Legacy exports are enabled, allowing developers to use them.

    2.0.0release notes