Title: `void/db` can't carry a D1 bookmark across requests · Issue #783 · voidzero-dev/void · GitHub
Open Graph Title: `void/db` can't carry a D1 bookmark across requests · Issue #783 · voidzero-dev/void
X Title: `void/db` can't carry a D1 bookmark across requests · Issue #783 · voidzero-dev/void
Description: Version void 1.7.0, and main at fecc1d4 Problem Follow-up to #755, which asked for two things. fecc1d4 shipped the first, createDb(env.DB, { session: 'first-primary' }), and closed the issue. The second, a bookmark that carries across re...
Open Graph Description: Version void 1.7.0, and main at fecc1d4 Problem Follow-up to #755, which asked for two things. fecc1d4 shipped the first, createDb(env.DB, { session: 'first-primary' }), and closed the issue. The s...
X Description: Version void 1.7.0, and main at fecc1d4 Problem Follow-up to #755, which asked for two things. fecc1d4 shipped the first, createDb(env.DB, { session: 'first-primary' }), and closed the issu...
Opengraph URL: https://github.com/voidzero-dev/void/issues/783
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`void/db` can't carry a D1 bookmark across requests","articleBody":"### Version\n\n`void` 1.7.0, and `main` at fecc1d4\n\n### Problem\n\nFollow-up to #755, which asked for two things. fecc1d4 shipped the first, `createDb(env.DB, { session: 'first-primary' })`, and closed the issue. The second, a bookmark that carries across requests, isn't tracked anywhere, so here it is on its own.\n\nEach request's `db` starts a new session on `first-unconstrained`. Within a request, reads see that request's writes. In the next request they may not: a write in one request followed by a read in the next can still reach a replica that hasn't caught up.\n\n`first-primary` fixes this one read at a time, but only if the app knows which reads follow a write. Most of the time it doesn't:\n\n- A form action saves and redirects, and the next page's loader shows the old data. Every loader that might run after any write would need `first-primary`, which gives up replicas for those pages entirely.\n- A user pays and the client visits a page gated on that payment. Reading the user with `first-primary` there works, but the page is reached in normal navigation far more often than after a payment, and those visits would lose the replica too. The same goes for every other page that shows the paid state.\n\nD1's own answer is the bookmark: save `session.getBookmark()` at the end of a request, and start the next request's session with `withSession(bookmark)`, so it sees at least everything the user has written.\n\nVoid can't do this yet, and neither can an app:\n\n- `createDb()`'s `session` option is a `D1SessionConstraint`, so it doesn't take a bookmark.\n- The request `db` doesn't expose its session's `getBookmark()`.\n\n### Proposal\n\nAn opt-in setting, such as `database: { bookmark: 'cookie' }` in `void.config.ts`. With it on, Void:\n\n1. starts each request's session from a bookmark cookie when there is one, and from `first-unconstrained` otherwise;\n2. sets the cookie to the session's `getBookmark()` when the response goes out, as `HttpOnly`, `SameSite=Lax`, with a short `Max-Age`, since a bookmark older than replica lag adds nothing.\n\nIf that's more than Void wants to own, the building blocks would let apps do it in middleware:\n\n- let `createDb()`'s `session` option take a bookmark string, as `withSession()` does;\n- expose the request session's bookmark, such as `getBookmark()` from `void/db`;\n- let middleware set the request `db`'s starting constraint or bookmark before the page runs.\n\n### Prior art\n\nRails' `DatabaseSelector` reads from the primary for a while after a user writes, tracked in the session cookie. Laravel's `sticky` option does the same within a request. Cloudflare's [read replication guide](https://developers.cloudflare.com/d1/best-practices/read-replication/) recommends passing the bookmark back to the client for exactly this case.\n","author":{"url":"https://github.com/karthickeyan-dev","@type":"Person","name":"karthickeyan-dev"},"datePublished":"2026-11-11T08:02:47Z","url":"https://github.com/voidzero-dev/void/issues/783"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf |
| 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:a10b11f2-444f-47dd-9310-06a14052c4cd |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A330:3B28F7:14D57A:1CD934:6AFB8BAD |
| html-safe-nonce | 43d540af9264ce4b0f9a375e767e7f2c9b2a6ab5cf5a97eee69ca39cbefabb84 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBMzMwOjNCMjhGNzoxNEQ1N0E6MUNEOTM0OjZBRkI4QkFEIiwidmlzaXRvcl9pZCI6Ijg5Njc2NjQyODAxNDQ2Nzc4MDUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 45e7d4e6e101dcc737803830afc329c5f81bc7e5b638bcf2fbaa20952bb30599 |
| hovercard-subject-tag | issue:6324262132 |
| 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/783/issue_layout |
| twitter:image | https://opengraph.githubassets.com/33aca3441ffdc422095fa0da6e58f501e47e63fa8e81aadbe054f926b4c0ec54/voidzero-dev/void/issues/783 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/33aca3441ffdc422095fa0da6e58f501e47e63fa8e81aadbe054f926b4c0ec54/voidzero-dev/void/issues/783 |
| og:image:alt | Version void 1.7.0, and main at fecc1d4 Problem Follow-up to #755, which asked for two things. fecc1d4 shipped the first, createDb(env.DB, { session: 'first-primary' }), and closed the issue. The s... |
| 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 | 9694464143465782ecae2a97650b2a2b0708d5c31c74f41ee86da57e315e2735 |
| 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 | 05d967182208691fc7f2e6af52e82fa7fabf6bd5 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width