D1 Session Read Replica
Cloudflare D1 read replication done so the write-then-redirect-then-read flow stays correct. Sequential consistency is scoped to one D1DatabaseSession, which dies with the Worker invocation, so a POST that INSERTs and answers 303 hands the follow-up GET a fresh unconstrained session that can read a replica behind the write. This carries session.getBookmark() across the redirect in a Set-Cookie, since a browser drops the redirect's custom headers and replays only cookies. Includes the constraint policy per route type (first-primary on writes to protect the read half of a read-modify-write, the incoming bookmark on the owner's dashboard, an explicit anonymous opt-out on the public cached feed), a commit that no-ops on a null bookmark and still fires on the 429 path, rejection of client-supplied constraint literals in the bookmark slot, and D1Meta served_by_primary logging.
npx shadcn@latest add https://ui.aryank.space/r/d1-session-read-replica.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 POST inserts at v42 and answers 303. The follow-up GET is a new Worker invocation with a fresh, unconstrained session, so a replica that has not caught up answers it at v41. Watch the version the reader sees roll backward past its own write: the user posts a comment and reloads to find it missing.
@cloudflare/[email protected]