# Known limits

- Prototype: the API may change between releases. Published on Hex, not on npm.
- Conflicts are detected only for actions that declare `base` and handlers that compare `meta.base` (see
  [Conflicts](conflicts.md)); every other call is accepted or refused on its own, last write wins. A conflict
  is resolved by the server's state, and by an optional resolver that sends the call again; nothing is merged.
  When an earlier call of the queue is confirmed, the bases of later ones move with the confirmed state, so a
  change another client made to a later call's record that reaches this client only inside that reply (rather
  than in an earlier patch) counts as seen. The window runs from the last patch of that record this client
  received to the server's handling of the earlier call: when the application patches every change to every
  client as it happens, it is about that handling; when it does not (no broadcast to the other LiveViews, or
  only some changes patched), it reaches back to the last time this client got that record, however long ago.
  With `record` declared on both calls this applies only to calls of the same record; without it, also to a
  later call on another record whose change the reply happens to carry. When the earlier call's own effect reached
  the client before its confirmation (a lost reply, then the reconnect's mount patch, or a patch from the
  handler) and both calls declared the same record, the client cannot tell that effect from another client's
  change of that record, so the window grows to everything up to that confirmation: the later call, based on
  the version the earlier one was sent with, does not conflict with such a change. Without `record` on both,
  that later call conflicts with the user's own edit instead. Equal versions of different records never move
  a base, as long as each action's `record` names the record its `base` reads, in a form that no action of the
  store gives to another record (`["task", id]` rather than the bare id; see [Conflicts](conflicts.md)).
- Delivery of server actions is at least once: a call whose reply was lost is sent again with the same
  `meta.id`, so handlers must be idempotent wherever running a call twice would be wrong.
- The retry limit counts pushes that got no reply (`maxAttempts`, 3 by default), including a push cut short
  by a reload or a flapping connection, so an unlucky call can be given up on although the server was
  healthy. It is kept as failed, for a retry with the same id (see [Failed pushes](persistence.md#failed-pushes)), or rolled
  back with `"push_failed"` with `keepFailed: false`.
- LiveView 1.2 reloads the page when a push (a server action or a mirrored value) gets no reply within 30
  seconds and its LiveView has not rejoined since the push was sent: `pushWithReply` in `view.ts` then
  calls `reloadWithJitter`, which disconnects the socket at once and reloads the page 5 to 10 seconds later
  (30 seconds after 10 consecutive reloads). That happens when the connection dies silently right after a
  push (the socket only notices through its heartbeat, which can take up to a minute) or when the server
  stays unreachable for over 30 seconds with a push in flight, and also when a `handle_action/4` or
  `handle_store/3` takes over 30 seconds. The bridge pushes nothing while `navigator.onLine` is false,
  which avoids the common offline case, but cannot rule out the others: the timeout is fixed and LiveView
  has no option to turn the reload off. The persisted state and queue survive the reload (a pending write
  is flushed on `pagehide`). A reload while offline shows the browser's offline page, unless the service
  worker of [Offline cold start](offline-cold-start.md) kept the page.
- Chunked loading (`live_slice/data`) has its own limits: no server-side index, no vector tiles, chunks
  replaced whole, memory bounded in chunks rather than bytes, and a cache subject to the browser's quota (see
  [Limits](large-data.md#limits)).
- Offline cold start needs the optional service worker and offline mount (see
  [Offline cold start](offline-cold-start.md)), and a first visit online: nothing is kept before the worker
  installed, after that page's `load` event.
- The service worker keeps nothing from other origins: the style and tiles of a basemap provider are not
  kept, so an offline map shows only what the app draws itself (the demo falls back to a plain background).
  An app may add its own `fetch` listener to its worker file, after `installServiceWorker`, to keep the
  origins it is allowed to (mind the provider's terms); requests live_slice does not handle reach it.
- Kept pages belong to the user who loaded them, with their data and session tokens; call
  `clearUserCaches()` on sign-out. They are also as old as the copy: server-rendered parts show what the
  server rendered then, until the LiveView joins. Recovery from a stale kept page relies on that join, so it
  covers LiveView pages only: a kept page without a LiveView, such as a plain form with an old CSRF token,
  stays as it is until the next load (see
  [What stays with LiveView](offline-cold-start.md#what-stays-with-liveview)).
- The offline mount takes object hooks only, and relies on LiveView's `[data-phx-session]` containers and
  its `phx:page-loading-stop` event with kind `"initial"` to tell a LiveView page and its join.
- Promises returned by server actions do not survive a reload; after one, `onRejected` and `onSettled` are
  the only way to learn how restored actions ended.
- Persisted values must survive the structured clone algorithm (IndexedDB); arguments of server actions must
  be JSON. Writes are coalesced and flushed when the page is hidden, but a crash (rather than a normal
  unload) can lose the changes of the last 100 ms, including actions queued in that window, and an action
  whose confirmation was not written yet is sent again after the reload.
- Tabs share the persisted queue and, by default, the persisted keys (`persist.share`), but not the keys
  that are not persisted; per-key last-write-wins can keep one tab's value of a key over a newer one another
  tab has not written yet. With tab coordination, an `apply` that
  throws while being replayed in any tab rejects that action in every tab, even one already on its way to
  the server, so prefer an `apply` that returns `undefined` over one that throws.
- Persisted state belongs to the browser profile and origin, not to a user. To clear it, for example when
  another user signs in, `await resetStores()` (it resolves once the writes in flight finished; writes
  still queued are dropped), then remove each record with the storage adapter
  (`await createIndexedDBStorage().remove("tasks")` for the default storage); for one store,
  `await removeStore("tasks", { clearPersisted: true })` does both, and tells the other open tabs, which stop
  writing the store and drop its persisted keys (see [Multiple tabs](tabs-and-connection.md#multiple-tabs)); after `resetStores()`
  and a removal by the storage adapter, other open tabs keep their stores and write their changes again, so
  reload them too.
- Collaborative keys (see [Limits of collaborative keys](collaborative-keys.md#limits-of-collaborative-keys)): the server cannot
  refuse an individual edit, only a reader or a writer of a whole document; a delete wins over a concurrent
  edit inside the deleted item; documents grow with their history; no awareness (cursors, presence), rich-text
  editor binding or undo; a slow persistence holds up its document, whose calls give up after 5 seconds;
  `LiveSlice.CRDT` runs on a single node; the default persistence is in memory, for demos; a server that lost
  a document gets it back from the clients, also one that was deleted on purpose; a server restored from a
  backup older than a document's last delete resets the clients that synced after it, which lose their local
  changes.
- Re-applying DOM bindings after a patch relies on the `phx:update` event that LiveView 1.2 dispatches on
  `document` at the end of every patch. The event is undocumented and could change in a later release.
- One store per LiveView: `use LiveSlice` can be used once, and `handle_store/3` and `handle_action/4` have
  no store argument. Other stores can still use patch, invalidate and DOM bindings through
  `<LiveSlice.bridge store={...} />`, which neither mirrors nor sends server actions.
- One LiveView per page sends a store's server actions: a second bridge with actions for the same store
  waits until the first is destroyed.
- Mirrored keys are used as written: there is no snake_case or camelCase conversion, so the JavaScript key
  `selectedId` is mirrored as `:selectedId`. Keys in `patch` maps reach the store as given.
- The MapLibre binding marks features with feature state only, by id: features without a stable numeric or
  string id cannot be selected or hovered. The hover, and a `cursor`, query rendered features on every
  `mousemove`.
- Bindings support top-level keys only (`catalog.selectedId`, not `catalog.selection.id`), and compare one
  value with `String(...)` equality.
- Bound classes are owned by the binding: if the server also renders one of them in `class`, the binding
  removes it while the binding is inactive.
- Bindings need a mounted bridge for their store on the page. `onBeforeElUpdated` alone only acts during
  patches.
- The mirror skips a push when the value equals what the server is known to hold. Primitives, arrays and
  plain objects compare by content; any other object (a `Date`, a `Map`, a class instance) compares by
  identity, so a new instance with the same content is pushed again.
