Skip to content
Source
Sign inSign up
TanStack/query

v5: solid-query key and data mismatch with `staleTime` set #5738

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

Describe the bug

There's data and key mismatch with staleTime configured using Solid Query v5 (only v5, v4 works as expected). In another setup (not the reproduction), the mismatch always happens whether staleTime is set or not.

Your minimal, reproducible example

https://stackblitz.com/edit/solid-query-key-and-data-mismatch

Steps to reproduce

  1. Go to the StackBlitz reproduction
  2. Wait for the dependencies installation and server to start
  3. Initially the select option set to One and the fetching starts for the key ['posts', '1']
  4. Change the select option to Two to fetch for ['posts', '2'] and the data below it will update
  5. Switch to option One with ['posts', '1'], the data will change as expected
  6. Switch back to option Two with ['posts', '2'] but it will keep showing data for key ['posts', '1'] ⚠️

Expected behavior

Switching between the two keys should return the data corresponding to each key.

How often does this bug happen?

Every time

Screenshots or Videos

No response

Platform

  • OS: macOS
  • Browser: Brave (Chromium-based)
  • Version: Brave v1.52.130 Chromium v114.0.5735.198

Tanstack Query adapter

solid-query

TanStack Query version

v5.0.0-alpha.85

TypeScript version

v5.1.3

Additional context

No response

  1. TkDodocommented

    hmm, this seems to work in v4. @ardeora do you think this is solid specific?

    working v4 reproduction

  2. TkDodo added labelsbug

  3. TkDodo added labelspackage: solid-query

  4. TkDodo added labelsv5

  5. This is a bug in the reconcile behavior. If you set reconcile: false in createQuery Option it should work as expected

  6. Thanks for your replies @TkDodo @ardeora. Indeed, disabling the reconcile option solves the data/key mismatch issue I had.

    Do you think that the reconcile bug could potentially cause other unexpected issues? If it makes sense to disable it globally until it's resolved.

  7. I was testing v5 today and using a query with a refetchInterval with a createEffect that uses query.data, the effect was not being called on each fetch but it was in v4, I solved it by setting reconcile to false, so I just wanted to let you know about it.

  8. Should be fixed in the new versions and up! v5.0.0-rc.8 If you could please update your dependency and check if it works as expected, that would be awesome :D

    Here is the reproduction with the new version https://stackblitz.com/edit/solid-query-key-and-data-mismatch-wjjhsu?file=package.json

  9. It's working as expected yes, thanks for the update!

Sign in to join this conversation.