unstale

npm / eventsource

eventsource

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

23 breaking2 new APIs and options1 performance3 behavior and defaults10 fixes and other

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

npx @unstale/cli init

@unstale/cli on npm

eventsource 522 changes

Breaking changes 9

  • Handlers assigned to onerror now have the EventSource instance as their declared this type; handlers with an incompatible this are rejected.

    5.1.0release notes

  • Handlers assigned to onmessage now have the EventSource instance as their declared this type; handlers with an incompatible this are rejected.

    5.1.0release notes

  • Handlers assigned to onopen now have the EventSource instance as their declared this type; handlers with an incompatible this are rejected.

    5.1.0release notes

  • 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.0release notes

  • 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.0release notesupgrade guide

  • The separate CommonJS variant is no longer published; Node.js 22.12 and later transparently supports require() of ESM.

    5.0.0release notesupgrade guide

  • 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.0release notesupgrade guide

  • 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.0release notesupgrade guide

  • Node.js 22.12 or later is now required; older versions are no longer supported or guaranteed.

    5.0.0release notesupgrade guide

New APIs and options 1

  • A new exported type describes the EventSource constructor for libraries that accept an implementation to construct.

    5.1.0release notes

Behavior and default changes 2

  • 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.0release notes

  • Reconnection timers are unrefed where the runtime supports it, so pending reconnects do not keep the process alive.

    5.0.0release notes

Fixes and other changes 10

  • URL objects are copied during construction, so later caller mutations do not change the exposed URL or reconnection target.

    5.1.4release notes

  • Avoids double-encoding non-ASCII event IDs during reconnects that use Cloudflare Workers' native fetch.

    5.1.3release notes

  • 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.3release notes

  • Accepts case variations of the MIME type and rejects different subtypes such as text/event-streaming.

    5.1.3release notes

  • Buffered messages stop dispatching when an event listener closes the connection.

    5.1.2release notes

  • The underlying request is aborted when a response fails EventSource validation.

    5.1.2release notes

  • ID-only event blocks now update the event ID used for Last-Event-ID on reconnect.

    5.1.1release notes

  • Message events now use the buffered last event ID when an event omits an id field, preserving the previous ID.

    5.1.1release notes

  • Message events dispatched on Cloudflare Workers now have lastEventId explicitly assigned when the constructor does not retain it.

    5.1.0release notes

  • Message events dispatched on Cloudflare Workers now have origin explicitly assigned when the constructor does not retain it.

    5.1.0release notes

eventsource 44 changes

Breaking changes 2

  • FetchLikeInit was removed; use EventSourceFetchInit instead.

    4.0.0release notes

  • Node.js v20 or higher is required; support for Node.js v18 was dropped.

    4.0.0release notes

New APIs and options 1

  • A fetch override support symbol is declared on the class, enabling typed fetch overrides.

    4.1.0release notes

Behavior and default changes 1

  • 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.1release notes

eventsource 311 changes

Breaking changes 11

  • Empty options no longer disable certificate checks.

    3.0.0release notes

  • dispatchEvent now emits the entire event object.

    3.0.0release notes

  • A custom fetch function can replace dropped headers, proxy, and https.* options.

    3.0.0release notes

  • The headers option in the init dict is dropped; pass a custom fetch function instead.

    3.0.0release notes

  • Built-in HTTP/HTTPS proxy support is dropped; pass a custom fetch function instead.

    3.0.0release notes

  • The https.* options are dropped; provide an agent or dispatcher through a custom fetch function instead.

    3.0.0release notes

  • The module uses a named export instead of a default export.

    3.0.0release notes

  • Node.js versions below v18 are no longer supported.

    3.0.0release notes

  • The default reconnect delay is 3 seconds instead of 1 second.

    3.0.0release notes

  • Reconnecting after a redirect always uses the original URL, including when the status code is HTTP 307.

    3.0.0release notes

  • The UMD bundle is no longer provided; use a bundler.

    3.0.0release notes

eventsource 22 changes

Breaking changes 1

Performance 1

  • Buffer size is preallocated when reading data, increasing performance with large messages.

    2.0.0release notes