unstale

npm / centrifuge

centrifuge

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

12 breaking4 new APIs and options8 behavior and defaults1 tooling20 fixes and other

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

npx @unstale/cli init

@unstale/cli on npm

centrifuge 543 changes

Breaking changes 12

  • Configuration errors such as no supported transport, no WebSocket implementation, or an http(s) endpoint string are thrown from connect() rather than leaving the client connecting or retrying.

    5.8.0release notes

  • Calls made while disconnected now fail instead of waiting for a connection until their timeout.

    5.8.0release notes

  • An exception in a client or subscription event handler disconnects the client without reconnecting, reports an unhandled rejection, and leaves the client consistent.

    5.8.0release notes

  • Other exceptions while handling a message stop the client with a visible disconnect instead of silently stopping processing while connected.

    5.8.0release notes

  • The subscription is removed before its unsubscribed event, allowing a handler to create a replacement on the same channel; removing an old object no longer removes the replacement.

    5.8.0release notes

  • Keys whose track fails permanently are untracked and each receives a removal update, rather than remaining tracked and replaying on every reconnect.

    5.8.0release notes

  • Shared poll update versions are numbers over the protobuf protocol rather than Long objects.

    5.8.0release notes

  • Protocol offsets are numbers rather than Long objects; positions stored by earlier versions and passed through since are converted, while offsets above 2^53 lose exactness.

    5.8.0release notes

  • Calling subscribe() on a removed subscription now throws instead of creating an untracked server subscription whose publications are dropped.

    5.8.0release notes

  • A static subscription token receiving error 109 ends unsubscribed with unauthorized code 1 and a configuration error instead of clearing the token and retrying without one.

    5.8.0release notes

  • Protobuf clients are imported as a named Centrifuge export instead of a default import.

    5.0.0release notes

  • The protocol option was removed from the Centrifuge instance config object.

    5.0.0release notes

New APIs and options 4

  • The client listens for page lifecycle events on pageEventTarget, defaulting to globalThis where supported; use a target that does not fire these events to opt out of back/forward cache handling.

    5.8.0release notes

  • A new getState callback is available for stream subscriptions.

    5.6.0release notes

  • Map subscriptions are added as a subscription type.

    5.6.0release notes

  • Shared Poll subscriptions are added as a subscription type.

    5.6.0release notes

Behavior and default changes 7

  • On persisted pagehide, the client closes its transport and moves to connecting; on persisted pageshow, it reconnects and recovers subscriptions.

    5.8.0release notes

  • Closing a transport aborts pending emulation requests; network failures and 404/5xx responses close the transport so the client reconnects without waiting for the command timeout.

    5.8.0release notes

  • The zero-delay first round over a transport list no longer counts towards reconnect backoff.

    5.8.0release notes

  • Pushes are delivered to a server-side subscription when a client-side subscription object for the same channel is not subscribed.

    5.8.0release notes

  • A new signature replaces stored signatures whose keys it fully covers.

    5.8.0release notes

  • Undecodable data closes the transport, after which the client reconnects using its usual backoff and transport fallback.

    5.8.0release notes

  • An imported Protobuf client automatically uses the Protobuf protocol, so callers no longer need to specify it in the constructor.

    5.0.0release notes

Tooling 1

  • The library is built with Rollup and supports both ESM and CommonJS, helping users integrate it with existing toolchains.

    5.0.0release notes

Fixes and other changes 19

  • Stream transport close is handled after received data is dispatched, so a disconnect push written immediately before close is applied.

    5.8.0release notes

  • Late call, no-ping, and connect timers allow already-received replies, pings, or open events to be processed first.

    5.8.0release notes

  • A channel the server does not recover no longer reports a failed recovery when positioning is enabled and a subscription has a position.

    5.8.0release notes

  • Without getToken, setToken() after a token-expired error clears the pending refresh so the next connect() uses the new token; with getToken, the next attempt still calls it.

    5.8.0release notes

  • track() calls made while a subscribe completes, such as from a subscribed handler, are sent with the replay that follows.

    5.8.0release notes

  • Updates with a version not newer than the held version for a key are dropped, preventing duplicate delivery and older updates replacing newer ones.

    5.8.0release notes

  • Without getToken, disconnect and unsubscribe state invalidation keeps the static token, allowing reconnect or resubscribe with it.

    5.8.0release notes

  • Fixes UTF-8 corruption when a character spans two stream chunks.

    5.7.4release notes

  • Byte counts for non-ASCII JSON payloads are corrected, so delta stats report accurate sizes.

    5.7.3release notes

  • Pending publish-debounce timers are canceled on reconnect.

    5.7.3release notes

  • The server-side subscription recovery position is reset when state is invalidated.

    5.7.3release notes

  • Prevents a crash when the final WebTransport read chunk has no value.

    5.7.3release notes

  • Fixes an out-of-bounds transport index during initialization.

    5.7.2release notes

  • Sets the _triedAllTransports flag when unsupported transports are skipped.

    5.7.2release notes

  • Fixes a localStorage access error in Safari private browsing mode.

    5.7.1release notes

  • Fixes edge cases in channel compaction.

    5.7.0release notes

  • Aligns state invalidation across both disconnect paths and unrecoverable resubscribe, with named codes.

    5.7.0release notes

  • Fixes a bug with instanceof checks for Array.

    5.5.2release notes

  • Fixes a TypeError caused by localStorage.getItem not being a function on NodeJS 25.

    5.5.1release notes

centrifuge 42 changes

Behavior and default changes 1

  • Returning an empty string is now valid and does not disconnect the client; throw UnauthorizedError() from getToken to disconnect it.

    4.0.0release notes

Fixes and other changes 1

  • The SDK adds setToken back, allowing the token to be reset to empty when a user logs out.

    4.0.0release notes