# What changed in eventsource-parser

> 13 changes in eventsource-parser 3 to 4 from its official release notes, upgrade guides and advisories: 4 breaking, 2 new APIs and options. Each one cited. Sources checked 2026-10-17. HTML: https://unstale.sh/npm/eventsource-parser/

To see which of these apply to a repository, run `npx @unstale/cli init` in it.

## eventsource-parser 4

### Breaking changes

- The CommonJS build and its `main` field and `require` export conditions are removed; Node 22.12 and above supports `require(esm)` transparently. (4.0.0) — [release notes](https://github.com/rexxars/eventsource-parser/releases/tag/v4.0.0)
- The package now requires Node.js >=22.12; Node.js 18 and 20 are no longer supported or guaranteed. (4.0.0) — [release notes](https://github.com/rexxars/eventsource-parser/releases/tag/v4.0.0)
- 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.0) — [release notes](https://github.com/rexxars/eventsource-parser/releases/tag/v4.0.0)
- The root `stream.js` file is removed; import `eventsource-parser/stream` instead and ensure your bundler resolves the `exports` field. (4.0.0) — [release notes](https://github.com/rexxars/eventsource-parser/releases/tag/v4.0.0)

### New APIs and options

- Adds a callback that reports ID fields when an event block ends, including blocks without data. (4.1.0) — [release notes](https://github.com/rexxars/eventsource-parser/releases/tag/v4.1.0)

### Behavior and default changes

- Partial comment lines are buffered only when an `onComment` callback is configured; otherwise, they are discarded. (4.0.0) — [release notes](https://github.com/rexxars/eventsource-parser/releases/tag/v4.0.0)

### Fixes and other changes

- Buffer limits are enforced while processing a chunk. (4.1.2) — [release notes](https://github.com/rexxars/eventsource-parser/releases/tag/v4.1.2)
- 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.1) — [release notes](https://github.com/rexxars/eventsource-parser/releases/tag/v4.1.1)
- A leading byte order mark is stripped whether it arrives as decoded `U+FEFF` or as the raw three-byte sequence. (4.0.0) — [release notes](https://github.com/rexxars/eventsource-parser/releases/tag/v4.0.0)

## eventsource-parser 3

### New APIs and options

- Adds the maxBufferSize option. (3.1.0) — [release notes](https://github.com/rexxars/eventsource-parser/releases/tag/v3.1.0)

### Performance

- Avoids O(N²) behavior when a single SSE event spans many chunks. (3.0.8) — [release notes](https://github.com/rexxars/eventsource-parser/releases/tag/v3.0.8)
- Parsing is ~3.75x faster via inline fast-paths and single-pass line processing. (3.0.7) — [release notes](https://github.com/rexxars/eventsource-parser/releases/tag/v3.0.7)

### Fixes and other changes

- An id: line containing a NULL character no longer wipes the buffered event id. (3.1.1) — [release notes](https://github.com/rexxars/eventsource-parser/releases/tag/v3.1.1)
