TanStack / TanStack/db

useLiveQuery returning stale results when querying local storage collection

Open
#471 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
3.9k
Forks
266
Avg merge
1d 4h
Merged PRs (30d)
55

Description

Changes to a local storage collection are successfully being persisted to local storage and useLiveQuery will return the updated data, but then revert back to the pre-modified data. Refreshing the window/tab then reflects the expected updated state. If I switch to a local only collection the issue no longer occurs. This doesn't happen everywhere I'm using useLiveQuery with the same local storage collection, so there is something unique about the way I'm using it combined with local storage. I'm not sure if I'll be able to make a repro case but curious if there is any idea of what might be going on ...

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the stale-result sequence around useLiveQuery and the local storage collection, comparing it with the local-only collection where the issue does not occur. Trace why updated data reverts after persistence, and consider the issue done when the updated collection state remains visible without refreshing the window or tab.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
database
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.