# What changed in eventsource

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

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

## eventsource 5

### Breaking changes

- Handlers assigned to onerror now have the EventSource instance as their declared this type; handlers with an incompatible this are rejected. (5.1.0) — [release notes](https://github.com/EventSource/eventsource/releases/tag/v5.1.0)
- Handlers assigned to onmessage now have the EventSource instance as their declared this type; handlers with an incompatible this are rejected. (5.1.0) — [release notes](https://github.com/EventSource/eventsource/releases/tag/v5.1.0)
- Handlers assigned to onopen now have the EventSource instance as their declared this type; handlers with an incompatible this are rejected. (5.1.0) — [release notes](https://github.com/EventSource/eventsource/releases/tag/v5.1.0)
- Response body reader chunks are now typed as Uint8Array | DataView | ArrayBuffer instead of unknown, so custom fetch implementations with wider chunk types may no longer be assignable. (5.1.0) — [release notes](https://github.com/EventSource/eventsource/releases/tag/v5.1.0)
- Support is dropped for Chrome before 84, Safari before 15, Firefox before 105, Edge before 84, and JavaScript environments without private fields, methods, and accessors. (5.0.0) — [release notes](https://github.com/EventSource/eventsource/releases/tag/v5.0.0)
- The separate CommonJS variant is no longer published; Node.js 22.12 and later transparently supports require() of ESM. (5.0.0) — [release notes](https://github.com/EventSource/eventsource/releases/tag/v5.0.0)
- When an on* property handler and an addEventListener() listener are registered for the same event, they run in registration order instead of always running the on* handler first. (5.0.0) — [release notes](https://github.com/EventSource/eventsource/releases/tag/v5.0.0)
- The parser now fails the connection and emits an error without reconnecting after buffering 100 MB without a valid, complete EventSource line; configure a different limit with maxBufferSize. (5.0.0) — [release notes](https://github.com/EventSource/eventsource/releases/tag/v5.0.0)
- Node.js 22.12 or later is now required; older versions are no longer supported or guaranteed. (5.0.0) — [release notes](https://github.com/EventSource/eventsource/releases/tag/v5.0.0)

### New APIs and options

- A new exported type describes the EventSource constructor for libraries that accept an implementation to construct. (5.1.0) — [release notes](https://github.com/EventSource/eventsource/releases/tag/v5.1.0)

### Behavior and default changes

- The exported EventSource type is now structural, allowing the native EventSource, mocks, and stubs with a matching shape to be assigned to it. (5.1.0) — [release notes](https://github.com/EventSource/eventsource/releases/tag/v5.1.0)
- Reconnection timers are unrefed where the runtime supports it, so pending reconnects do not keep the process alive. (5.0.0) — [release notes](https://github.com/EventSource/eventsource/releases/tag/v5.0.0)

### Fixes and other changes

- Avoids double-encoding non-ASCII event IDs during reconnects that use Cloudflare Workers' native fetch. (5.1.3) — [release notes](https://github.com/EventSource/eventsource/releases/tag/v5.1.3)
- Sends event IDs as UTF-8 bytes on reconnect, preventing fetch errors and ensuring IDs with non-ASCII characters are encoded as specified. (5.1.3) — [release notes](https://github.com/EventSource/eventsource/releases/tag/v5.1.3)
- Accepts case variations of the MIME type and rejects different subtypes such as text/event-streaming. (5.1.3) — [release notes](https://github.com/EventSource/eventsource/releases/tag/v5.1.3)
- Buffered messages stop dispatching when an event listener closes the connection. (5.1.2) — [release notes](https://github.com/EventSource/eventsource/releases/tag/v5.1.2)
- The underlying request is aborted when a response fails EventSource validation. (5.1.2) — [release notes](https://github.com/EventSource/eventsource/releases/tag/v5.1.2)
- ID-only event blocks now update the event ID used for `Last-Event-ID` on reconnect. (5.1.1) — [release notes](https://github.com/EventSource/eventsource/releases/tag/v5.1.1)
- Message events now use the buffered last event ID when an event omits an id field, preserving the previous ID. (5.1.1) — [release notes](https://github.com/EventSource/eventsource/releases/tag/v5.1.1)
- Message events dispatched on Cloudflare Workers now have lastEventId explicitly assigned when the constructor does not retain it. (5.1.0) — [release notes](https://github.com/EventSource/eventsource/releases/tag/v5.1.0)
- Message events dispatched on Cloudflare Workers now have origin explicitly assigned when the constructor does not retain it. (5.1.0) — [release notes](https://github.com/EventSource/eventsource/releases/tag/v5.1.0)

## eventsource 4

### New APIs and options

- A fetch override support symbol is declared on the class, enabling typed fetch overrides. (4.1.0) — [release notes](https://github.com/EventSource/eventsource/releases/tag/v4.1.0)

### Behavior and default changes

- Done-results now allow a value of any type, so custom fetch implementations returning Response-shaped bodies satisfy FetchLikeResponse with TypeScript 5.9 and newer. (4.1.1) — [release notes](https://github.com/EventSource/eventsource/releases/tag/v4.1.1)
