Open History to see the last commit
1/**
2 * SSR entry for the disabled-query regression test.
3 *
4 * A transcription of the reproduction from the issue: no boundary, one
5 * provider, one disabled query whose `.data` is read during render. A
6 * disabled query has nothing in flight and nothing cached, so the read has
7 * nothing to wait on and the stream has to finish. The absence of a
8 * boundary is the point β a regression must not be able to hide by parking
9 * inside one.
10 *
11 * Reports `finished: false` on a timeout instead of hanging, so a
12 * regression surfaces as an assertion rather than an unsettled top-level
13 * await.
14 */
15import { renderToStream } from '@solidjs/web'
16import {
17 QueryClient,
18 QueryClientProvider,
19 useQuery,
20} from '@tanstack/solid-query'
21β
22const RENDER_TIMEOUT = 8000
23β
24let fetches = 0
25β
26function Disabled() {
27 const query = useQuery(() => ({
28 queryKey: ['disabled'],
29 queryFn: () => {
30 fetches++
31 return Promise.resolve('data')
32 },
33 enabled: false,
34 }))
35 return (
36 <div id="out">
37 {String(query.data)}|{query.status}|{String(query.isEnabled)}
38 </div>
39 )
40}
41β
42const client = new QueryClient()
43β
44const result = await new Promise<{ finished: boolean; html: string }>(
45 (resolve) => {
46 let html = ''
47 const timer = setTimeout(
48 () => resolve({ finished: false, html }),
49 RENDER_TIMEOUT,
50 )
51 renderToStream(() => (
52 <QueryClientProvider client={client}>
53 <Disabled />
54 </QueryClientProvider>
55 )).pipe({
56 write(payload: string) {
57 html += payload
58 },
59 end() {
60 clearTimeout(timer)
61 resolve({ finished: true, html })
62 },
63 })
64 },
65)
66β
67console.log(JSON.stringify({ ...result, fetches }))
68// A parked render leaves handles open; exit rather than wait them out.
69process.exit(0)