I was getting the same issue using @tanstack/[email protected].
Setting cacheTime: 0 solved it for me.
In version 5, cacheTime has been renamed to gcTime as per https://tanstack.com/query/latest/docs/framework/react/guides/migrating-to-v5#rename-cachetime-to-gctime