Skip to content

octane/data: cross-tab store ownership (RFC phase 6) #2532

Closed

Description

@trueadm

Phase 6 of the octane/data RFC (#2362): one store per account, shared by every tab of compatible builds.

Where things stand

Phases 1–5 have landed:

Today each tab opens its own createDataStore. So two tabs of one account each load the same reads, hold their own feed connections, and keep their own copy of the write journal. They share only what the persistent cache and the journal partition hold, and that sharing is not coordinated.

Goal

A SharedWorker owns the account's store across tabs. Each tab renders read-only snapshots from it and sends its writes to it. One load, one feed connection and one rollback then serve every tab, and a write journaled in one tab is never recovered twice.

Parts

  1. Shared owner. The worker holds reads, the cache, feed connections and the journal. Tabs subscribe to snapshots and dispatch validated writes. useRead, useReadState, usePages, useFeed and useForm keep their current behavior in both bindings, including synchronous snapshots for hydration.
  2. Compatibility handshake. Tabs share a worker only when their build's contracts and protocol match. A tab on an incompatible build keeps its own store and never reads the worker's state.
  3. Account fencing. Every snapshot and reply carries the account generation. After an account switch, or while the device is locked, a tab that was frozen shows nothing until it has read the current account decision. Late replies for a retired generation are dropped.
  4. Fallback and crash recovery. Where SharedWorker is unavailable, each tab keeps its own store, as today. A tab or worker crash does not lose a journaled write, does not send one twice, and does not reveal another account's data.

Acceptance (from the RFC)

  • Two compatible builds share one read and observe the same rollback.
  • Freeze a tab, switch accounts while it is locked, time out the acknowledgement, and crash the initiator and the worker. On resume, the tab reveals data only after reading the durable account decision.
  • An incompatible build falls back to its own store with no access to the shared one.
  • The same scenarios pass in the Octane and React bindings.

Open design questions

To settle in a short design note before code:

  • Ownership split: what the worker owns, and what stays in the tab. For example: view evaluation, optimistic projections, form drafts and focus.
  • Snapshot protocol: whole snapshots or patches per read, and how a tab keeps getSnapshot synchronous across the worker boundary, during hydration in particular.
  • Compatibility: what "compatible build" means. One option is a hash of contract names, schema shapes and protocol version.
  • The server render's seed: how it reaches the worker when the worker already holds newer values.
  • Testing: how to run SharedWorker scenarios in CI. Browser tests are likely, with a fallback-only path under jsdom.
  • Bundle cost: a tab that uses the worker should not also ship the full store.

Activity

  1. trueadm commented on Nov 12, 2026

    @trueadm
    CollaboratorAuthor

    Status: none of the cross-tab work here has started yet. The PRs linked from this issue (#2540, #2541, #2542, #2545, #2546, #2547 and #2548) are correctness fixes to the phases that have already landed: write lifetime, refresh ordering, recovery durability, feed disconnects, seed snapshots, form identity and read keys. They aren't the shared-worker owner, the handshake or account fencing described above. Each one has review feedback posted. #2541 currently adds a request per write in apps with a feed, which is why Shelf's e2e fails on it.

  2. trueadm commented on Nov 18, 2026

    @trueadm
    CollaboratorAuthor

    Phase 6 is complete on main. It landed in #2559 (owner/replica protocol), #2560 (SharedWorker host and the dataWorker plugin option), #2572 (account fencing), #2583 (compatibility handshake, fallback and crash recovery), #2594 and #2625 (the owner as the only writer of the cache and journal, and settling writes in flight after a crash) and #2629 (reconciling the server's seed across tabs, with the shared-tab test also run on the React page). Later fixes are in #2940, #2941 and #2997. The acceptance cases have tests: the Shelf e2e covers the frozen-tab account switch, and data-owner.test.ts covers freeze, resume, handshake and crash. The design is in docs/data-cross-tab-plan.md.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions