You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Remote D1 binding: withSession() ignores constraints and bookmarks #403
In remote mode (remote: true), the D1 binding accepts withSession(), but it does not keep the D1 session contract:
app code remote D1 binding today
----------------------------------------- ------------------------------------------
db.withSession('first-primary') → returns the same binding; constraint ignored
session.prepare(sql).run() → proxy request has binding/sql/params/method only
session.getBookmark() → always null
db.withSession(savedBookmark) → bookmark ignored
Each statement is a separate proxy call that runs on the deployed binding without a session. void/db and auth work (#402 added withSession() so they no longer crash). But code that depends on bookmarks sees a different contract in remote development than in production. For example, it cannot carry a bookmark between requests, and getBookmark() never returns a value.
Code: packages/void/src/runtime/remote/d1.ts (ProxyD1Database.withSession, getBookmark) and the proxy handler platform/packages/proxy/src/d1.ts.
What a fix needs
client proxy (deployed binding)
ProxyD1DatabaseSession ── query/batch ─► db.withSession(constraint or bookmark)
{ constraint | bookmark } run the statement(s)
◄──────── result + bookmark ───── session.getBookmark()
store the new bookmark
withSession() returns a new session object for each call. Two sessions do not share state.
Each query and batch request sends the session's constraint (first call) or its latest bookmark.
The proxy handler runs the request in db.withSession(...) and returns session.getBookmark() with the result. The client stores it.
An older proxy that does not know sessions fails with a clear error. The client must not act as if bookmarks work.
Tests
first-primary, first-unconstrained, and a bookmark from an earlier request.
A query and then a batch move the bookmark forward.
Two sessions keep separate bookmarks.
A real client → proxy round trip, and the error against an older proxy.
Activity
fix: high-severity bugs in the CLI, runtime and adapters (#402)