Repository navigation
fix(client): a server render answers every read an on-demand collection makes - #62
Merged
Merged
Conversation
A request that an earlier watch covers loads with a cursor-less fetch, and SsrSnapshotTransport rejects every fetch, so the covered query goes to error in the render. Pins both mount orders, a single ordered limited query (core sends it covered requests on 0.9 and later), the dehydrate and hydrate round trip with the min cursor, and that a cursor fetch still fails loud. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A request that an open or pending watch covers loads its rows with a cursor-less fetch (ADR-0023 D2). SsrSnapshotTransport rejected every fetch, so in a server render a covered query went to error, and on @tanstack/db 0.9 and later so did a single orderBy + limit query. The snapshot transport now answers a fetch without a cursor with one snapshot read of the same where/orderBy/limit; its position joins the render's MIN cursor. A cursor fetch (load more) still rejects with SsrReadOnlyError. The adapter and the WebSocket transport are unchanged. Recorded as a dated amendment to ADR-0011. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A render refuses writes, never reads. Pins a cursor request inside a first load (0.9 and later), a window that moves during the render (a cursor request on 0.8.x), the row that a render's two reads of one cursor request both return, and a cursor request whose reads have writes between them, through dehydrate and hydrate. Closes the review's test gaps: a covered query whose row only its fetch brings, a covered fetch's own orderBy, a default sort window that only the full-source request corrects, a tie request, and two collections on one transport. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…eads Core sends a cursor request inside the first load of an ordered, limited query (0.9 and later, with an index and an order it can express as a cursor, when the window is underfilled), so refusing it failed renders the browser serves. SsrSnapshotTransport now reads the boundary ties and(where, whereCurrent) without a limit, then the page and(where, whereFrom) with it, through the existing read. Both join the MIN cursor. No change to the read request and no server change. A row that moves past the boundary between the two reads is in both; the next commit writes it once. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A render reads the two halves of a cursor request at two positions, so one row can be in both, and a second sync insert of the key fails the load on @tanstack/db 1.0. installPage now skips a key written earlier in the same page: insert-if-absent inside the page as well as against held rows. The first copy wins; the hydration catch-up from the MIN cursor brings the newer value. A server page never repeats a key, so the WebSocket path is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Rewrites the ADR-0011 amendment of 2026-11-17: every fetch is answered, the two-position reasoning for a cursor request and both of its races, the rows a render may read (measured: top 10 of 100 000 under the default sort reads 100 010 and dehydrates 100 000 on 0.9 and later; 11 and 10 with stringSort lexical), what an app sees for a refused predicate on each side, and the rejected options. Dates insert-if-absent inside one page in ADR-0003. README: the SSR rule and a warning about ordered queries. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The server refuses it as a malformed cursor; the snapshot transport read the whole table. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The server refuses it as a malformed cursor because the ties read would be an unbounded scan; the snapshot transport read the whole table. It now rejects loud, as a render does for every refused read. The adapter never sends such a frame; SsrSnapshotTransport is public. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
README: the full read also follows a NULL at the end of the first page (any type, any sort) and reads a boundary tie group whole; a fetch is one or two reads; a refused request is the one difference from the socket. ADR-0011: the malformed cursor refusal, a third two-position effect (a row read early and deleted later is still rendered), and the cursor shapes for which a server page never repeats a key. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…on makes Merges the SSR fix: a fetch without a cursor is one snapshot read, a fetch with a cursor is the two reads the server makes, and a fetched page writes each key once. Adds the changelog entries. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A server render of an on-demand collection failed whenever one of its queries was answered by a fetch.
SsrSnapshotTransportrejected every fetch withSsrReadOnlyError, so the query went toerror.That happened in three ordinary cases:
@tanstack/db0.9 and later, a single query withorderByandlimit, because core sends extra requests for the full source, for ties, and for an underfilled window;What changed
readrequest.Things to know
On 0.9 and later, core asks for every matching row when a limited query is ordered by text with the default sort, or when the first page ends on a NULL in the order column. A render now reads and ships those rows, as the browser already loads them over the socket. Top 10 of 100,000 rows under the default sort dehydrates 100,000. With
stringSort: "lexical"it dehydrates 10. The README's SSR section has the warning.A request the server refuses fails the render, where the socket answers it with no rows.
Verification
Not run: the full suite on 0.9.2, a numeric order column, and
examples/ssr, which uses an eager collection and so never reached this path.The decisions are recorded as a dated amendment to ADR-0011 and a note in ADR-0003.
🤖 Generated with Claude Code