Title: `void/db` can't start on the D1 primary or carry a bookmark across requests · Issue #755 · voidzero-dev/void · GitHub
Open Graph Title: `void/db` can't start on the D1 primary or carry a bookmark across requests · Issue #755 · voidzero-dev/void
X Title: `void/db` can't start on the D1 primary or carry a bookmark across requests · Issue #755 · voidzero-dev/void
Description: Version void 1.7.0 Problem Follow-up to #337, which asked for read replication and per-request sessions. During a request, db from void/db always starts with withSession('first-unconstrained'), and each request gets a new session. That c...
Open Graph Description: Version void 1.7.0 Problem Follow-up to #337, which asked for read replication and per-request sessions. During a request, db from void/db always starts with withSession('first-unconstrained'), and...
X Description: Version void 1.7.0 Problem Follow-up to #337, which asked for read replication and per-request sessions. During a request, db from void/db always starts with withSession('first-unconstrained...
Opengraph URL: https://github.com/voidzero-dev/void/issues/755
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`void/db` can't start on the D1 primary or carry a bookmark across requests","articleBody":"### Version\n\n`void` 1.7.0\n\n### Problem\n\nFollow-up to #337, which asked for read replication and per-request sessions.\n\nDuring a request, `db` from `void/db` always starts with `withSession('first-unconstrained')`, and each request gets a new session. That covers read-your-writes within one request, but not across requests: a write followed by a read in the next request can reach a replica that hasn't caught up.\n\nThe D1 guide says to handle this like so:\n\n> If another read must start with the latest primary data, use `env.DB.withSession('first-primary')` from `cloudflare:workers`.\n\nThat's the raw D1 API, and there's no supported way to run Drizzle queries on it:\n\n- `createDb()` calls `withSession('first-unconstrained')` itself, so it can't be given a different constraint.\n- `createPrimaryDb()` exists in `src/runtime/db.ts`, but it's private and only used outside a request.\n- Using `drizzle()` directly needs `drizzle-orm` as a dependency, and `void/db` is meant to replace that.\n\nSo a read that must be fresh has to become raw SQL with hand-written row types.\n\nThis affects common flows:\n\n- A form saves and redirects, and the next page's loader shows the old data.\n- A user pays and is sent to a page gated on that payment, and a replica says they haven't paid.\n- A webhook looks up a row created by an earlier request and doesn't find it.\n\n### Proposal\n\n1. A way to get a Drizzle `db` that starts on the primary and keeps the app's schema, such as `createDb(env.DB, { session: 'first-primary' })` or an exported `primaryDb`.\n2. An opt-in bookmark that carries across requests: Void saves `getBookmark()` in a cookie when a request ends and starts the next request's session from it, so a user always sees their own writes.\n\nEither one would solve the gated-page case. The first suits individual reads and also covers webhooks, which have no cookie. The second fixes the redirect-after-write case across a whole app.\n\n### Prior art\n\nRails' `DatabaseSelector` and Laravel's `sticky` option both send a user's reads to the primary after they write.\n","author":{"url":"https://github.com/karthickeyan-dev","@type":"Person","name":"karthickeyan-dev"},"datePublished":"2026-11-09T08:30:23Z","url":"https://github.com/voidzero-dev/void/issues/755"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:3bbf791c-94cc-b62d-8306-3c383061f0f9 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E3A8:3497D1:458052:5F6949:6AFB9C87 |
| html-safe-nonce | 2379b0ff97f34f953d833d3840bff09b154ae56c208dbb265cb6552c4dd32cd5 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFM0E4OjM0OTdEMTo0NTgwNTI6NUY2OTQ5OjZBRkI5Qzg3IiwidmlzaXRvcl9pZCI6IjI1MDQyNjMzNDg5NjMyMjA2MTUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | b1e3a55d1cd41113628dc79992327eb17bf7e7b1ced52d42c61f0992421f3eda |
| hovercard-subject-tag | issue:6282651919 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/voidzero-dev/void/755/issue_layout |
| twitter:image | https://opengraph.githubassets.com/bd4302ab803e1ff855303776ab1dff1e3af3e5203e6505c73bfe1ea0bc5365be/voidzero-dev/void/issues/755 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/bd4302ab803e1ff855303776ab1dff1e3af3e5203e6505c73bfe1ea0bc5365be/voidzero-dev/void/issues/755 |
| og:image:alt | Version void 1.7.0 Problem Follow-up to #337, which asked for read replication and per-request sessions. During a request, db from void/db always starts with withSession('first-unconstrained'), and... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | karthickeyan-dev |
| hostname | github.com |
| expected-hostname | github.com |
| None | 3cefd19a936819d82cfb5279d50fb56fe79cb9ec30f0f807e04e89b0c58ffae1 |
| turbo-cache-control | no-preview |
| go-import | github.com/voidzero-dev/void git https://github.com/voidzero-dev/void.git |
| octolytics-dimension-user_id | 149750581 |
| octolytics-dimension-user_login | voidzero-dev |
| octolytics-dimension-repository_id | 1164437080 |
| octolytics-dimension-repository_nwo | voidzero-dev/void |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1164437080 |
| octolytics-dimension-repository_network_root_nwo | voidzero-dev/void |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 606800bdb1b81d125fc845bdcc262c9fe063fc8f |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width