Zero 0.22

Simplified TTLs

Install

npm install @rocicorp/zero@0.22

Upgrading

This release simplifies the concept of TTLs in Zero.

See hello-zero, hello-zero-solid, or ztunes for example upgrades.

This release also adds anonymous telemetry collection. You can opt-out with the DO_NOT_TRACK=1 environment variable. Though we hope you will not, as it helps us improve Zero.

How TTLs Used to Work

Previously, the TTL of a query simply measured normal "wall clock time" from when a query inactivated, including any time the app wasn't running at all.

With experience, we realized this was a misfeature because it encouraged the use of very long or infinite TTLs, especially for preload queries. Developers always want preload queries registered, but since they do not know how long the app will be offline, they had no real choice but to use the TTL forever.

These infinite TTLs would remain registered even after the app's code changed such that it no longer wanted them, slowing connections and incremental updates to process queries that the app was not even using.

Worse, the prevalence of infinite TTLs in turns meant we needed some way to limit the size of the client cache. We introduced the "client row limit" for this. But developers would frequently accidentally blow through this limit, causing cache thrash.

How TTLs Work Now

Now, query TTLs measure "TTL time" which only elapses while Zero is running. This means that preload queries usually don't need a TTL at all, since they run the entire time Zero is active. This in turn means we can clamp TTLs to low values, which means queries evict naturally, which means we no longer need the client row limit either.

Using New TTLs

You don't need to do anything specific to upgrade. Zero will clamp your TTLs at 10m and print a warning.

But for best results, please review the new TTL documentation. In particular, see how to set your TTLs (TL;DR: You can often just remove them – the defaults usually just work).

Features

  • Rework and simplify query TTLs (docs, upgrading).
  • SolidJS bindings are now fine-grained, improving performance (PR).
  • Restore ZERO_CHANGE_STREAMER_URI option (doc, PR).
  • Add useZeroOnline to React and SolidJS bindings (doc).
  • Add ttl to run() (PR).
  • Allow client to specify push.url in the Zero constructor (doc).
  • Add anonymous telemetry collection to zero-cache (doc).

Fixes

  • Handle public in aliases, like .from('public.table') (PR).
  • Sorting by columns with null values was incorrect in some cases (PR).
  • Fix fencepost issue editing queries with limits (PR).
  • Fix copy runner to more reliably reuse connections (PR).
  • Queries early in startup could not contain non-latin chars (PR).
  • SolidJS: Export createUseZero (PR).
  • Support parallel rollouts of replication-manager and view-syncer (PR).
  • Fix upgrade path for already replicated array types (PR).

Breaking Changes