Describe the bug
constquery=queryOptions({queryKey: ['foo'],queryFn: async()=>{console.log('fetch');awaitnewPromise((resolve)=>setTimeout(resolve,1000));return[];},});constExample: FC=()=>{// ✅ This runs the `queryFn` once.// useSuspenseQuery(query);// ❌ This runs the `queryFn` twice. See console logs.const{ promise }=useQuery({
...query,experimental_prefetchInRender: true,});React.use(promise);return<div>loaded</div>;};Your minimal, reproducible example
https://stackblitz.com/edit/tanstack-query-5tk7d9bg?file=src%2Findex.tsx&preset=node
Steps to reproduce
See above.
Expected behavior
queryFn is only called once.
How often does this bug happen?
None
Screenshots or Videos
No response
Platform
N/A
Tanstack Query adapter
None
TanStack Query version
5.90.12
TypeScript version
No response
Additional context
Note this happens even when use is in a child component:
constChild: FC<{promise: Promise<any>}>=({ promise })=>{React.use(promise);return<div>loaded</div>;}constExample: FC=()=>{const{ promise }=useQuery({
...query,experimental_prefetchInRender: true,});return<Childpromise={promise}/>;};
Describe the bug
Your minimal, reproducible example
https://stackblitz.com/edit/tanstack-query-5tk7d9bg?file=src%2Findex.tsx&preset=node
Steps to reproduce
See above.
Expected behavior
queryFnis only called once.How often does this bug happen?
None
Screenshots or Videos
No response
Platform
N/A
Tanstack Query adapter
None
TanStack Query version
5.90.12
TypeScript version
No response
Additional context
Note this happens even when
useis in a child component: