Skip to content

Commit e88aaab

Browse files
ryansolidClaude via Cursorcursoragent
committed
test(release-gate): migrate the TanStack fixture off sharedConfig and onto the live-shell latch until upstream does; fail on install/type-check errors; refetch the fixture
The rc.12 release stopped at the TanStack Solid Query gate: `sharedConfig` is `@internal` since rc.12, so the adapter's type-check fails with TS2305 (QueryClientProvider.tsx, cacheAggregate.ts, useBaseQuery.ts). The public hydration API replaces it; until the adapter migrates upstream, the gate applies that migration (tests/patches/tanstack-solid-query-public- hydration.diff) to the fetched fixture. Self-removing: the patch applies only while the fixture still imports `sharedConfig` from solid-js, fails the gate if it no longer covers every such import, and is skipped once upstream has none. The adapter's "cache writes during the open stream commit when hydration completes" test pins the latch behavior the previous commit fixes (a shell write waiting for the whole page to hydrate). While the fetched fixture still carries that test, the gate rewrites it to the new expectation (tests/patches/tanstack-solid-query-hydration-latch.diff: the write commits to the shell at once). Self-removing the same way: applied only while the old title is present, failing the gate if the title survives the patch, skipped once upstream renames or rewrites it (TanStack/query#11751). Delete both blocks and patch files after that. Two gate bugs fixed on the way: - gitly serves its cached tarball first for any ref but master/main, so the gate kept re-testing the first `solid-query-v6-pre` download; `download(..., { force: true })` fetches the branch head. - shelljs's `exec` has no per-call `fatal` (only the global config), so a failed `pnpm install` or `pnpm run compile` (the adapter's type-check) returned silently. Both now run through a spawn helper that fails the gate on a non-zero exit or a signal; `npm pack` checks its exit code. SKIP_SOLID_QUERY_GATE in scripts/release.mjs is unchanged. Co-authored-by: Claude via Cursor <[email protected]> Co-authored-by: Cursor <[email protected]>
1 parent b68a907 commit e88aaab

3 files changed

Lines changed: 391 additions & 8 deletions

File tree

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
diff --git a/packages/solid-query/src/__tests__/hydration.test.tsx b/packages/solid-query/src/__tests__/hydration.test.tsx
2+
index 60d28d582..3acf9e01c 100644
3+
--- a/packages/solid-query/src/__tests__/hydration.test.tsx
4+
+++ b/packages/solid-query/src/__tests__/hydration.test.tsx
5+
@@ -507,14 +507,14 @@ describe('streaming SSR hydration', () => {
6+
}
7+
})
8+
9+
- // The data node has default ('server') hydration semantics: the
10+
- // serialized server value owns the DOM for the whole hydration window,
11+
- // and a latched node that recomputes mid-stream (a cache write landed)
12+
- // arms the engine's hydration-end takeover — the change commits when the
13+
- // stream closes, deferred rather than lost. Network activity is NOT
14+
- // deferred: observers attach per-query as the channel primes, so
15+
- // mid-stream invalidations refetch immediately.
16+
- it('cache writes during the open stream commit when hydration completes', async () => {
17+
+ // The data node has default ('server') hydration semantics, but once the
18+
+ // root pass is done a node outside every pending streamed boundary is
19+
+ // live: a cache write that lands while a slower boundary still streams
20+
+ // commits to the DOM immediately instead of waiting for the whole page to
21+
+ // hydrate. Network activity is not deferred either: observers attach
22+
+ // per-query as the channel primes, so mid-stream invalidations refetch
23+
+ // immediately.
24+
+ it('cache writes during the open stream commit outside pending boundaries', async () => {
25+
const { phase1, phase2 } = splitStream()
26+
const app = bundle.createStreamApp()
27+
const container = document.createElement('div')
28+
@@ -533,39 +533,42 @@ describe('streaming SSR hydration', () => {
29+
// The slow section still shows its fallback.
30+
expect(container.querySelector('#feed')).toBeNull()
31+
32+
- // A write while the stream is open reaches the CACHE immediately but
33+
- // not the DOM — the serialized server value holds the document.
34+
+ // A write while the stream is open reaches the cache and the DOM: the
35+
+ // header sits outside the still-pending slow boundary.
36+
app.queryClient.setQueryData(['header'], 'updated-client')
37+
- await tick(30)
38+
+ await vi.waitFor(() => {
39+
+ expect(container.querySelector('#header')?.textContent).toBe(
40+
+ 'updated-client',
41+
+ )
42+
+ })
43+
expect(app.queryClient.getQueryData(['header'])).toBe('updated-client')
44+
- expect(container.querySelector('#header')?.textContent).toBe(
45+
- 'header-server',
46+
- )
47+
+ // The slow section still shows its fallback.
48+
+ expect(container.querySelector('#feed')).toBeNull()
49+
50+
// An invalidation while the stream is open refetches immediately
51+
- // (the observer is subscribed — network is not deferred), but the
52+
- // result is held with the rest.
53+
+ // (the observer is subscribed — network is not deferred), and its
54+
+ // result commits as well.
55+
void app.queryClient.invalidateQueries({ queryKey: ['header'] })
56+
await vi.waitFor(() => {
57+
expect(app.counts.header).toBe(1)
58+
})
59+
- expect(container.querySelector('#header')?.textContent).toBe(
60+
- 'header-server',
61+
- )
62+
+ await vi.waitFor(() => {
63+
+ expect(container.querySelector('#header')?.textContent).toBe(
64+
+ 'header-client',
65+
+ )
66+
+ })
67+
68+
- // The late boundary hydrates, closing the stream — the divergence
69+
- // takeover re-runs the latched node and the held state commits.
70+
+ // The late boundary hydrates its server content, leaving the header
71+
+ // as it was.
72+
applyChunks(container, phase2)
73+
await vi.waitFor(() => {
74+
expect(container.querySelector('#feed')?.textContent).toBe(
75+
'feed-server',
76+
)
77+
})
78+
- await vi.waitFor(() => {
79+
- expect(container.querySelector('#header')?.textContent).toBe(
80+
- 'header-client',
81+
- )
82+
- })
83+
+ expect(container.querySelector('#header')?.textContent).toBe(
84+
+ 'header-client',
85+
+ )
86+
expect(app.counts.feed).toBe(0)
87+
88+
// And fully live from then on.
Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
1+
diff --git a/packages/solid-query-devtools/src/clientOnly.tsx b/packages/solid-query-devtools/src/clientOnly.tsx
2+
index 1d0dc6d..591db21 100644
3+
--- a/packages/solid-query-devtools/src/clientOnly.tsx
4+
+++ b/packages/solid-query-devtools/src/clientOnly.tsx
5+
@@ -1,9 +1,9 @@
6+
import {
7+
createMemo,
8+
createSignal,
9+
+ isHydrating,
10+
omit,
11+
onSettled,
12+
- sharedConfig,
13+
untrack,
14+
} from 'solid-js'
15+
import { isServer } from '@solidjs/web'
16+
@@ -30,8 +30,8 @@ export default function clientOnly<T extends Component<any>>(
17+
let Comp: T | undefined
18+
let m: boolean
19+
const rest = omit(props, 'fallback')
20+
- if ((Comp = comp()) && !sharedConfig.hydrating) return Comp(rest)
21+
- const [mounted, setMounted] = createSignal(!sharedConfig.hydrating)
22+
+ if ((Comp = comp()) && !isHydrating()) return Comp(rest)
23+
+ const [mounted, setMounted] = createSignal(!isHydrating())
24+
onSettled(() => {
25+
setMounted(true)
26+
})
27+
diff --git a/packages/solid-query/src/QueryClientProvider.tsx b/packages/solid-query/src/QueryClientProvider.tsx
28+
index 8e1797a..676fb52 100644
29+
--- a/packages/solid-query/src/QueryClientProvider.tsx
30+
+++ b/packages/solid-query/src/QueryClientProvider.tsx
31+
@@ -1,5 +1,5 @@
32+
-import { createContext, onCleanup, sharedConfig, useContext } from 'solid-js'
33+
-import { REVALIDATE_HEADER } from '@solidjs/web'
34+
+import { createContext, isHydratable, onCleanup, useContext } from 'solid-js'
35+
+import { REVALIDATE_HEADER, getHydrationWriter } from '@solidjs/web'
36+
import { hydrate } from '@tanstack/query-core'
37+
import { subscribeFlightData } from '@solidjs/web/server-functions'
38+
import type { DehydratedState, Query } from '@tanstack/query-core'
39+
@@ -148,16 +148,8 @@ export type QueryClientProviderProps = {
40+
* serialize, so seroval's cross-reference dedupe emits it once.
41+
*/
42+
function serializeCacheOnServer(client: QueryClient): void {
43+
- const ctx = (
44+
- sharedConfig as unknown as {
45+
- context?: {
46+
- async?: boolean
47+
- noHydrate?: boolean
48+
- serialize: (key: string, value: unknown) => void
49+
- }
50+
- }
51+
- ).context
52+
- if (!ctx || !ctx.async || ctx.noHydrate) return
53+
+ const writer = getHydrationWriter()
54+
+ if (!writer || !writer.async || !isHydratable()) return
55+
56+
const cache = client.getQueryCache()
57+
// The standard dehydrate filter gates the wire here too, so apps keep
58+
@@ -175,7 +167,7 @@ function serializeCacheOnServer(client: QueryClient): void {
59+
const state = query.state
60+
if (state.status === 'success') {
61+
seen.add(query.queryHash)
62+
- ctx.serialize(HYDRATION_KEY_PREFIX + query.queryHash, {
63+
+ writer.write(HYDRATION_KEY_PREFIX + query.queryHash, {
64+
data: state.data,
65+
t: state.dataUpdatedAt,
66+
})
67+
@@ -185,7 +177,7 @@ function serializeCacheOnServer(client: QueryClient): void {
68+
const promise = query.promise as Promise<unknown> | undefined
69+
if (!promise) return
70+
seen.add(query.queryHash)
71+
- ctx.serialize(
72+
+ writer.write(
73+
HYDRATION_KEY_PREFIX + query.queryHash,
74+
promise.then(() => ({
75+
data: query.state.data,
76+
diff --git a/packages/solid-query/src/cacheAggregate.ts b/packages/solid-query/src/cacheAggregate.ts
77+
index d08ab86..6beeacb 100644
78+
--- a/packages/solid-query/src/cacheAggregate.ts
79+
+++ b/packages/solid-query/src/cacheAggregate.ts
80+
@@ -2,8 +2,8 @@ import {
81+
createEffect,
82+
createOptimistic,
83+
createSignal,
84+
+ isHydrating,
85+
onCleanup,
86+
- sharedConfig,
87+
untrack,
88+
} from 'solid-js'
89+
import type { Accessor } from 'solid-js'
90+
@@ -47,8 +47,7 @@ export function createCacheAggregate<T>(
91+
read: (prev: T) => T,
92+
empty: T,
93+
): Accessor<T> {
94+
- const hydratedMount =
95+
- !isServer && (sharedConfig as { hydrating?: boolean }).hydrating === true
96+
+ const hydratedMount = isHydrating()
97+
98+
// Cast: createSignal's value overload excludes functions (a function
99+
// argument means a compute); aggregate values are counts and arrays.
100+
diff --git a/packages/solid-query/src/useBaseQuery.ts b/packages/solid-query/src/useBaseQuery.ts
101+
index f469a27..7486950 100644
102+
--- a/packages/solid-query/src/useBaseQuery.ts
103+
+++ b/packages/solid-query/src/useBaseQuery.ts
104+
@@ -7,10 +7,11 @@ import {
105+
isPending as isValuePending,
106+
onCleanup,
107+
resolve,
108+
+ isHydrating,
109+
runWithOwner,
110+
- sharedConfig,
111+
untrack,
112+
} from 'solid-js'
113+
+import { takeHydrationValue } from '@solidjs/web'
114+
import { HYDRATION_KEY_PREFIX, useQueryClient } from './QueryClientProvider'
115+
import { useIsRestoring } from './isRestoring'
116+
import type { UseBaseQueryOptions, UseBaseQueryResult } from './types'
117+
@@ -166,12 +167,10 @@ export function useBaseQueryLayer<
118+
)
119+
120+
/**
121+
- * `sharedConfig.hydrating` is Solid's own "this component is being
122+
- * hydrated" flag, captured at setup. (The server build's sharedConfig
123+
- * has no such field — undefined there, and unused.)
124+
+ * Solid's own "this component is being hydrated" answer, captured at
125+
+ * setup. Always false on the server.
126+
*/
127+
- const hydratedMount =
128+
- !isServer && (sharedConfig as { hydrating?: boolean }).hydrating === true
129+
+ const hydratedMount = isHydrating()
130+
131+
/**
132+
* One version signal per hook, bumped by cache events for this query hash.
133+
@@ -336,10 +335,6 @@ export function useBaseQueryLayer<
134+
135+
if (!isServer) {
136+
cacheSub = activeClient.getQueryCache().subscribe(onCacheEvent)
137+
- const sc = sharedConfig as unknown as {
138+
- has?: (id: string) => boolean
139+
- load?: (id: string) => any
140+
- }
141+
const registryKey =
142+
HYDRATION_KEY_PREFIX + untrack(defaultedOptions).queryHash
143+
const primeAndAttach = (entry?: Partial<HydratedEntry> | null) => {
144+
@@ -348,24 +343,12 @@ export function useBaseQueryLayer<
145+
attach()
146+
}
147+
const settle = hydratedMount ? primeAndAttach : prime
148+
- if (sc.has?.(registryKey)) {
149+
- const entry = sc.load!(registryKey)
150+
- delete (globalThis as unknown as { _$HY: { r: Record<string, unknown> } })
151+
- ._$HY.r[registryKey]
152+
- if (entry != null && typeof entry === 'object') {
153+
- // Settled serialization refs are stamped `s`/`v`; still-streaming
154+
- // ones are plain thenable refs that land with their chunk.
155+
- if (entry.s === 1) settle(entry.v)
156+
- else if (entry.s === 2) settle()
157+
- else if (typeof entry.then === 'function')
158+
- entry.then(settle, () => settle())
159+
- else settle(entry)
160+
- } else {
161+
- settle(entry)
162+
- }
163+
- } else if (hydratedMount) {
164+
- primeAndAttach()
165+
- }
166+
+ const entry = takeHydrationValue<Partial<HydratedEntry> | null>(registryKey)
167+
+ if (entry?.status === 'resolved') settle(entry.value)
168+
+ else if (entry?.status === 'rejected') settle()
169+
+ else if (entry?.status === 'pending')
170+
+ entry.promise.then(settle, () => settle())
171+
+ else if (hydratedMount) primeAndAttach()
172+
if (!hydratedMount) {
173+
createRenderEffect(
174+
() => isRestoring(),
175+
@@ -544,7 +527,7 @@ export function useBaseQueryLayer<
176+
* priming; if a fetch is genuinely needed, the post-priming observer
177+
* attach issues it outside the window.
178+
*/
179+
- if (!isServer && (sharedConfig as { hydrating?: boolean }).hydrating) {
180+
+ if (isHydrating()) {
181+
return NEVER
182+
}
183+
/**

0 commit comments

Comments
 (0)