Describe the bug
When using the same useLiveQuery with a where and orderBy clause in multiple components, query logic tends to break.
To Reproduce
Steps to reproduce the behavior:
- Clone this repo
pnpm install && pnpm dev
- Go to
localhost:3000
- Click the
decrement all button a few times, then click the change name button a few times, UI should break unexpectedly.
Expected behavior
- The DB stores a list of items, each with an index, independent UUID (which is used as the key), and name.
- The UI contains 4 identical
<List> components, each one has a useLiveQuery that views the list of items whose indices are between 1 and 4 inclusive. It then sorts the list items.
- Clicking on
decrement all in the UI will decrement each item's index value and should update the list displays accordingly.
- Clicking on
change name in the UI will add a + at the end of each item's name, it should update the list displays accordingly.
Screenshots
Initial state.
After clicking on decrement all once.
After clicking on decrement all and change name a few times.
Desktop (please complete the following information):
- OS: 25.11.20260113.2c3e5ec (Xantusia)
- Browser: Firefox
- Version: 146.0.1
Additional context
- I am not well-versed in the internals of Tanstack DB but I believe this is a
solid-db specific issue, as it seems like the collection itself is internally consistent, collection.subscribeChanges also fires events correctly, and generally, everything outside of useLiveQuery works appropriately.
- I also have a more complex environment where I am using
@tanstack/solid-db and again, the failure seems to be concentrated within the useLiveQuery, synchronization mechanism. If I replace useLiveQuery with a manual setState(Array.from(collection.entries())), everything updates correctly.
orderBy works fine without where.
where works without orderBy.
- All logic works if I only have 1
<List> component.
Describe the bug
When using the same
useLiveQuerywith awhereandorderByclause in multiple components, query logic tends to break.To Reproduce
Steps to reproduce the behavior:
pnpm install && pnpm devlocalhost:3000decrement allbutton a few times, then click thechange namebutton a few times, UI should break unexpectedly.Expected behavior
<List>components, each one has auseLiveQuerythat views the list of items whose indices are between 1 and 4 inclusive. It then sorts the list items.decrement allin the UI will decrement each item's index value and should update the list displays accordingly.change namein the UI will add a+at the end of each item's name, it should update the list displays accordingly.Screenshots
Desktop (please complete the following information):
Additional context
solid-dbspecific issue, as it seems like the collection itself is internally consistent,collection.subscribeChangesalso fires events correctly, and generally, everything outside ofuseLiveQueryworks appropriately.@tanstack/solid-dband again, the failure seems to be concentrated within theuseLiveQuery, synchronization mechanism. If I replaceuseLiveQuerywith a manualsetState(Array.from(collection.entries())), everything updates correctly.orderByworks fine withoutwhere.whereworks withoutorderBy.<List>component.