Skip to content

Releases

v1.2.1

Choose a tag to compare

@joschan21 joschan21 released this 23 Nov 15:46

Emits no longer lock the whole database

  • emit() locks only its channel. The emit script now declares allow-key-locking, so Upstash holds a lock on the channel's key while the script runs instead of the database-wide lock. Other commands on your database no longer wait for an emit, and Upstash can run emits to different channels in parallel, up to your plan's parallelism.
  • Order is unchanged. Emits to one channel still run one after another, so delivery order keeps matching stream order.

Upgrading

  • No code changes. Events are stored and published exactly as in 1.2.0, and instances on 1.2.0 and 1.2.1 can run side by side.
  • emit() needs an Upstash database. Stock Redis, for example behind SRH, rejects the script with ERR Unexpected flag in script shebang: allow-key-locking.

Full change: c867c14

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

v1.2.0-canary.0

v1.2.0-canary.0 Pre-release
Pre-release

Choose a tag to compare

@joschan21 joschan21 released this 17 Nov 13:52

Canary of the performance work on josh/realtime-perf.

  • emit() stores and publishes an event in one round trip instead of two
  • SSE connections served by one instance share a Redis subscription per channel
  • The keepalive pings a channel only when it has been idle
  • The client reconnects only when its set of channels changes, and drops events it already delivered
  • Server-side subscribe() stops its keepalive when unsubscribed
  • emit() refuses events over 1,000,000 characters, which could not be delivered
  • Requires @upstash/redis 1.36.1 or newer

Install with npm install @upstash/realtime@canary.

v1.1.1

Choose a tag to compare

@ytkimirti ytkimirti released this 12 Nov 13:40
36dc43c

What's Changed

New Contributors

Full Changelog: v1.1.0...v1.1.1

v1.1.1-canary.0

v1.1.1-canary.0 Pre-release
Pre-release

Choose a tag to compare

@ytkimirti ytkimirti released this 12 Nov 13:34
36dc43c

Canary build of 36dc43c for verification before the stable release.

v1.1.0

Choose a tag to compare

@joschan21 joschan21 released this 29 Jul 07:16

Cursor-based resumption for server-side subscriptions

Every event delivered by a server-side subscribe() now carries an opaque cursor. Pass the last handled cursor back as after to resume exactly where you left off — missed events are replayed from the stream, then live delivery continues with automatic deduplication:

await realtime.channel("jobs").subscribe({
  events: ["job.updated"],
  after: storedCursor,
  onData(message) {
    handleJobUpdate(message.data)
    saveCursor("jobs", message.cursor)
  },
})
  • A trimmed, expired or malformed cursor rejects the subscription with the new CursorUnavailableError, so you can reload canonical state and start fresh.
  • after and history are mutually exclusive, enforced at the type level and at runtime.
  • RealtimeCursor is a branded string; narrow stored values with the exported isRealtimeCursor guard before passing them to after.
  • Failed history replays now reject the subscribe() promise and clean up the underlying Redis subscription instead of hanging.
  • Stream-id comparison uses BigInt, so sequence numbers beyond 2^53 order correctly.

See docs/server-side-cursor-resumption.md for a full usage guide.

Compatibility notes

  • onData payloads gain a cursor property, and the exported UserEvent["id"] type is now branded — a type-level change for TypeScript consumers constructing UserEvent values manually. Hence the minor version bump.
  • Event ids are now validated against the Redis stream-id format (^\d+-\d+$) everywhere. Events published to a channel by hand (raw redis.publish with a custom id, bypassing emit()) are silently dropped from delivery. Use emit(), which mints valid ids via XADD.

Thanks @smorimoto for the contribution (#26, closes #25).

1.0.4

Choose a tag to compare

@joschan21 joschan21 released this 13 Jul 11:47
d9df563

What's Changed

Fixes

  • Prevent event loss during history replay (#24, fixes #23): subscribe({ history: true }) could silently drop events published while the XRANGE history replay was in flight, because the pub/sub message listener was only registered after replay finished. Listeners are now registered up front; live events arriving during replay are buffered, delivered after the historical entries, and deduplicated against the last replayed stream id — including on the post-replay pub/sub path, since emit runs XADD before PUBLISH and the same event can arrive through both.
  • Fixed a leaked ping interval when a subscriber unsubscribes while history replay is still running.

Internal

  • Added a bun test regression suite covering the replay race, both deduplication paths, and the unsubscribe-during-replay case.

Thanks @smorimoto for the report and fix!

Full Changelog: v1.0.3...v1.0.4

1.0.3

Choose a tag to compare

@joschan21 joschan21 released this 27 Feb 09:39
1202688

Minor fix included from #18

Upstash Realtime 1.0 Canary

Pre-release

Choose a tag to compare

@joschan21 joschan21 released this 26 Nov 12:51

1.0 Canary version for Upstash Realtime