Commit c8c2a19
fix(e2e): hydration infinite-loop — drop broken use-sync-external-store polyfill, adopt gell-v2 optimizeDeps + PLAYWRIGHT env
Root cause (from Playwright trace artifacts on run 26543764735):
console: 'The result of getServerSnapshot should be cached to avoid
an infinite loop'
console: 'Maximum update depth exceeded'
console: 'Warning: Error in route match: __root__/'
SSR rendered perfectly (the dehydrated HTML has <h1>Tasks</h1>, the
session user, the empty task list — the whole shell). On the client,
hydration hit React's infinite-loop guard and tore the DOM down, so
'getByText("Tasks")' resolved to undefined for every test. ALL 15
e2e tests failed for the same reason — not just the public-marketing
subset that flaked under the earlier dep bump.
The source: src/polyfills/use-sync-external-store-shim.ts (lines
19-23) returned 'selector(getSnapshot())' as a brand-new arrow
function on every render. React's useSyncExternalStore reads the
snapshot fn and detects the new closure as a snapshot change, which
schedules a re-render, which creates another new closure, infinite
loop. TanStack 1.149 happened not to trigger this path; 1.167 does.
Three changes:
1. vite.config.ts: drop the resolve.alias block that pointed every
'use-sync-external-store/shim*' specifier at the broken polyfill.
Vite resolves the real package (v1.6.0, already in node_modules,
peerDeps include React 19) via optimizeDeps.
src/polyfills/use-sync-external-store-shim.ts deleted — gell-v2
keeps an identical file as dead code but never aliases it; we
delete instead to keep the polyfills/ dir honest.
2. vite.config.ts: optimizeDeps restructured to match gell-v2.
- include: 8 deps Vite would otherwise discover on first request
(TanStack history/router-core + helpers). Pre-bundling at
startup prevents the 'optimized → reloading' mid-flight
invalidation that crashes hydrating pages.
- exclude: better-auth ecosystem (server-only by design — TSS-2
keeps them out of the client graph), jose / @noble/* /
h3-v2 (server-only transitive deps).
- force: true when PLAYWRIGHT=true (stale-hash references from a
prior CI run can't break the first request).
The previous include list shipped @better-auth/core/* + h3-v2 to
the client optimizer pass — opposite direction from what TSS-2
demands. Caught here, but worth flagging as a near-miss.
3. playwright.config.ts: PLAYWRIGHT=true added to webServer.env so
the optimizeDeps.force kicks in. vite.config.ts also reads it for
server.hmr.overlay=false (the TanStack Start streaming-warning
overlay otherwise intercepts Playwright clicks —
TanStack/router#3584) and
server.watch.ignored=['**/routeTree.gen.ts'] (Router's
watchChange handler self-feeds otherwise).
Quality gates: check-types ✓, biome ci ✓, check-tss-2 ✓ (8
createServerFn files clean), 62 unit tests pass.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>1 parent 8a5656f commit c8c2a19
3 files changed
Lines changed: 54 additions & 86 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
60 | | - | |
| 60 | + | |
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
| |||
This file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | 1 | | |
3 | 2 | | |
4 | 3 | | |
| |||
32 | 31 | | |
33 | 32 | | |
34 | 33 | | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
35 | 51 | | |
36 | 52 | | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | 53 | | |
53 | 54 | | |
54 | 55 | | |
| |||
144 | 145 | | |
145 | 146 | | |
146 | 147 | | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | | - | |
155 | | - | |
156 | | - | |
157 | | - | |
158 | | - | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
159 | 161 | | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | | - | |
182 | | - | |
183 | 162 | | |
184 | 163 | | |
185 | | - | |
186 | 164 | | |
187 | 165 | | |
188 | | - | |
189 | | - | |
190 | 166 | | |
191 | | - | |
192 | | - | |
193 | | - | |
194 | | - | |
195 | 167 | | |
196 | 168 | | |
197 | | - | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
198 | 189 | | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
199 | 193 | | |
200 | 194 | | |
0 commit comments