Skip to content

Commit 2bbe0e7

Browse files
committed
fix: solid query hangs when not prefetchInRender
1 parent 38b4008 commit 2bbe0e7

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

examples/solid/solid-start-streaming/src/routes/index.tsx

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,25 @@
11
import { Title } from '@solidjs/meta'
2+
import { queryOptions, useQuery } from '@tanstack/solid-query'
3+
import { Suspense } from 'solid-js'
4+
5+
const makeQueryOptions = (key: string) =>
6+
queryOptions({
7+
queryKey: ['e2e-test-query-integration', key],
8+
queryFn: async () => {
9+
console.log('fetching query data')
10+
await new Promise<void>((resolve) => {
11+
setTimeout(resolve, 500)
12+
})
13+
const result = 'data'
14+
console.log('query data result', result)
15+
return result
16+
},
17+
staleTime: Infinity,
18+
})
219

320
export default function Home() {
21+
const query = useQuery(() => makeQueryOptions('useQuery'))
22+
423
return (
524
<main>
625
<Title>Solid Query v5</Title>
@@ -12,6 +31,10 @@ export default function Home() {
1231
streaming support. Use the links in the top left to navigate between the
1332
various examples.
1433
</p>
34+
35+
<Suspense>
36+
<div data-testid="query-data">{query.data ?? 'loading...'}</div>
37+
</Suspense>
1538
</main>
1639
)
1740
}

packages/query-core/src/queryObserver.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,11 @@ export class QueryObserver<
8484
this.#client = client
8585
this.#selectError = null
8686
this.#currentThenable = pendingThenable()
87+
if (!this.options.experimental_prefetchInRender) {
88+
this.#currentThenable.reject(
89+
new Error('experimental_prefetchInRender feature flag is not enabled'),
90+
)
91+
}
8792

8893
this.bindMethods()
8994
this.setOptions(options)

0 commit comments

Comments
 (0)