Describe the bug
Take some queries that are 1) allowed to be stale, 2) are combined into something:
const ids = [1, 2, 3];
const combinedQueries = useQueries({
queries: ids.map((id) => ({
queryKey: ["post", id],
queryFn: () => Promise.resolve(id),
staleTime: 30_000, // ← 1️⃣
})),
combine: i => i, // ← 2️⃣
});
and 3) are persisted in localStorage:
const persister = createAsyncStoragePersister({ storage: window.localStorage });
const queryClient = new QueryClient();
<PersistQueryClientProvider
client={queryClient}
persistOptions={{ persister }}
>
In this setup, when the persister finishes deserializing the queries, and the queries aren’t stale yet, useQueries will not call combine (unless combine’s identity changes). As a result, combinedQueries will remain in isPending: true state until staleTime expires.
This only reproduces with a custom combine function, even if it simply returns the same value.
Your minimal, reproducible example
https://codesandbox.io/p/sandbox/wqrzzm
Steps to reproduce
To repro the issue:
- Open the codesandbox
- Confirm the preview shows “Pending: false, false, false. Data: 1, 2, 3”
- Reload the preview a few times
- Confirm the preview shows “Pending: true, true, true. Data: , ,” every time
The issue disappears if you pass a different `combine` on every render
- Unwrap
combine on line 27 from useCallback
- Reload the preview a few times
- Confirm the preview shows “Pending: false, false, false. Data: 1, 2, 3” every time
The issue disappears if you don’t pass `combine` at all
- Remove
combine on line 38
- Reload the preview a few times
- Confirm the preview shows “Pending: false, false, false. Data: 1, 2, 3” every time
Expected behavior
As a user, I expect to see “Pending: false, false, false. Data: 1, 2, 3” on every reload. However, I actually see “Pending: true, true, true. Data: , ,” starting with the second load.
How often does this bug happen?
Every time
Screenshots or Videos
No response
Platform
Tanstack Query adapter
None
TanStack Query version
v5.85.5
TypeScript version
No response
Additional context
No response
Describe the bug
Take some queries that are 1) allowed to be stale, 2) are combined into something:
and 3) are persisted in
localStorage:In this setup, when the persister finishes deserializing the queries, and the queries aren’t stale yet,
useQuerieswill not callcombine(unlesscombine’s identity changes). As a result,combinedQuerieswill remain inisPending: truestate untilstaleTimeexpires.This only reproduces with a custom
combinefunction, even if it simply returns the same value.Your minimal, reproducible example
https://codesandbox.io/p/sandbox/wqrzzm
Steps to reproduce
To repro the issue:
The issue disappears if you pass a different `combine` on every render
combineon line 27 fromuseCallbackThe issue disappears if you don’t pass `combine` at all
combineon line 38Expected behavior
As a user, I expect to see “Pending: false, false, false. Data: 1, 2, 3” on every reload. However, I actually see “Pending: true, true, true. Data: , ,” starting with the second load.
How often does this bug happen?
Every time
Screenshots or Videos
No response
Platform
Tanstack Query adapter
None
TanStack Query version
v5.85.5
TypeScript version
No response
Additional context
No response