-
Notifications
You must be signed in to change notification settings - Fork 180
Description
- I've validated the bug against the latest version of DB packages
Describe the bug
When combining offline transactions with queryCollection and the refetchOnReconnect option is enabled, there's a race between the immediate refetch of server state and the pending transactions being sent to the server. This can result in the state reverting to the pre-mutation state until the next stale time is reached.
This can be worked around by force-refreshing after mutations are applied, but on slow network connections or API operations this could result in UI "blips" where the state reverts for a few moments before being updated. This also results in redundant queries being made and simply isn't useful behaviour.
To Reproduce
Steps to reproduce the behavior:
- Configure
@tanstack/offline-transactions+@tanstack/query-db-collection. - Setup a query function + offline mutation.
- Go offline and queue a mutation.
- Come back online, the collection will fetch immediately and reset the DB state before transactions are applied.
Expected behavior
The query should be blocked from refetching until pending transactions have been applied.
Screenshots
The red line is when the system is offline, the green is immediately after coming online. stream is the queryFn and is called immediately, and then called again manually after a mutation to the correct the state.
