Skip to content
Source
Sign inSign up
TanStack/db

Ordered loader: an offset-only provider leaves a joined on-demand window empty at preload #2182

Send to my agent
OpenKyleAMathews(GitHub profile, opens in a new tab) opened this issue 0 comments

Summary

An on-demand ordered live query with a joined filter shows an empty window at preload when the provider honors offset but not cursor. LoadSubsetOptions allows either encoding.

Reproduction

The pinned witness is an offset-only provider fills a joined window at preload (known loader defect) in packages/query-db-collection/tests/refetch-ordered-prefix-oracle.test.ts (branch fix-query-db-refetch-ordered-gap, PR #2154). It is an it.fails test today.

  • Source: an on-demand Query Collection whose queryFn applies where, sorts, skips offset rows and applies limit. It ignores cursor.
  • Query: rank desc, limit 1, LEFT join to a marker Collection, keep rows that have a marker.
  • Rows: ids 0, 1, 2, all rank 0. Only row 0 has a marker. With one order term the fixture rank is rank * 100 + id, so the order is 2, 1, 0.

Expected window: [0]. Actual window: [] (expected [] to deeply equal [ +0 ]).

Cause (from the oracle's notes, not yet traced in detail)

The loader repeats a continuation offset that it caps at the window size. The offset-only provider then answers the same rows again, and the loader never reaches row 0.

Scope

This reproduces on main. It is separate from #2136. The query-db refetch oracle's generated campaigns use a cursor provider only, because of this defect.

Suggested witness and owner

  • Owner: the ordered loader (packages/db/src/query/live/ordered-source-loader.ts). Read ARCHITECTURE.md "Ordered requests, continuation, and recovery" first.
  • Witness: flip the pinned it.fails test to a normal test. Then let the query-db refetch oracle's generated scenario choose encoding: offset too.

This issue was written by Isaac.

Sign in to join this conversation.