Skip to content

v1.2.0

Choose a tag to compare

@joschan21 joschan21 released this 17 Nov 14:51
c0ebc4f

Faster, with far less load on Redis

  • emit() takes one round trip instead of two. An event is stored and published by one script call. In our tests emit latency halved (211 ms to 105 ms on a distant database, 54 ms to 26 ms on a nearby global one).
  • Connections share Redis subscriptions. The SSE connections one instance serves now share one Redis subscription per channel, instead of each opening their own. For 1,000 clients on a channel that is one subscription instead of 1,000, and about 19x less CPU per delivered event on Node.
  • The keepalive only pings idle channels. Before, every connection published a ping every minute and every connection on the channel received each of them. Now a channel gets about one ping per idle minute in total.
  • Server-side subscribe() stops its keepalive when unsubscribed. Before, each closed subscription kept publishing a ping every minute.
  • The client reconnects only when its channels change. A hook mounting or unmounting no longer replaces the connection, and events a hook already received are not delivered again.
  • A subscription that silently stops receiving is noticed within about a minute, and clients resume from their last event.

Upgrading

  • Requires @upstash/redis 1.36.1 or newer. Older versions lose subscription messages that span two network reads.
  • emit() refuses events over 1,000,000 characters, which could not be delivered.
  • Channel names the Redis SDK cannot subscribe to (containing /, \, ?, #, % or a comma) are served from history only by the handler; server-side subscribe() rejects all of those except a comma.
  • Error frames sent to clients carry fixed text; the details stay in the server log.

Full change: #30