Turso Replica Read Your Writes
Read-your-writes for Turso embedded replicas, using the replication frame number as a session watermark. An embedded replica inverts the latency model: reads are a local SQLite file at microsecond latency and writes go to the remote primary, so a read issued right after a write can be answered by a replica that has not pulled it yet, and the author reloads into a page missing their own comment. commitWrite returns the frame_no that Client.sync() resolves to, readAtLeast pulls until the replica reaches it, and a replica that cannot catch up inside the deadline escalates to the primary rather than serving a fast wrong answer. syncInterval cannot do this: it bounds how old data gets, never how old it is relative to your own write. Also survives sync() rejecting with an empty error code on a non-replica client, which is what the local development configuration does. Pinned to @libsql/[email protected].
npx shadcn@latest add https://ui.aryank.space/r/turso-replica-read-your-writes.jsonInstalls from ui.aryank.space. To add it by hand, copy the files in Files below, or register the @compronents namespace via the docs.
The comment commits on the remote primary at frame 42 and the POST answers 303. The follow-up GET is served from a local replica file still sitting at frame 41, because syncInterval bounds how old data gets, never how old it is relative to your own write. Watch the frame the reader sees stay behind the write it just made: the author reloads into a page missing their own comment, and every local test passed because locally there is only one file.
@libsql/[email protected]