Skip to content

solid-v2/fullstack-tanstack: multi-source single-flight - #287

Draft
ryansolid wants to merge 2 commits into
mainfrom
flight-data-source
Draft

solid-v2/fullstack-tanstack: multi-source single-flight#287
ryansolid wants to merge 2 commits into
mainfrom
flight-data-source

Conversation

@ryansolid

@ryansolid ryansolid commented Aug 29, 2026

Copy link
Copy Markdown
Member

Draft — do not merge until three releases ship: the @solidjs/web release after 2.0.0-rc.4 (multi-source single-flight protocol, solidjs/solid@653dd41e), the @tanstack/solid-query release after 6.0.0-rc.1 carrying TanStack/query#11326, and the @tanstack/solid-router release carrying TanStack/router#8192. A version-bump commit lands here at that point.

Summary

This template is the reference for pairing TanStack Router + Query with Solid's native channels — every piece composed from public APIs along its natural boundary, no integration package.

  • App.tsx drops the hand-rolled client half of single-flight (subscribeFlightData + hydrate): QueryClientProvider now subscribes the query cache's consumer internally under FLIGHT_DATA_SOURCE ("sq").
  • server-config.ts registers the collector additively under FLIGHT_DATA_SOURCE — so another cache's flight data could coexist on the same mutation response — and the collector itself is now a two-primitive composition: loadFlightTarget (the router's trigger: derive the flight request for the post-mutation URL, run the matched routes' data functions) + dehydrateSettled (the cache's extraction: wait out the loaders' fire-and-forget prefetches, then dehydrate). The local settled() helper is gone.
  • App.tsx gains the last stretch of redirect glue: cache-driven fetches (background refetches, mutations) run outside the router, so a queryFn/mutationFn throwing redirect() would settle into cache error state with nobody navigating. The client boot now hands redirect errors from both caches to router.navigate — a dozen lines composing isRedirect/resolveRedirect with the caches' config.onError. Loader-driven redirects were already the router's own on both sides (the server answers a real 30x via setup.tsx).

Net: the template's single-flight surface shrinks to just the server-side data strategy, which is the only genuinely app-specific part — and the whole Router+Query pairing needs no *-ssr-query integration package: SSR transfer is the provider's hydration registry, post-mutation transfer is the flight envelope, redirect handling is the composition above.

Test plan

  • After version bumps: pnpm build, vitest suite, and the browser e2e (hydration, login/rename/logout, single-flight list refresh) against the published packages.

Made with Cursor

ryansolid and others added 2 commits August 28, 2026 23:49
Solid's single-flight channel is becoming multi-source (solidjs/solid
653dd41e) and solid-query internalizes the client half
(TanStack/query#11326): QueryClientProvider subscribes the query cache's
consumer under FLIGHT_DATA_SOURCE ("sq") itself. The template drops its
hand-rolled client wiring (subscribeFlightData + hydrate in App.tsx) and
registers the server collector under the same source id with
registerFlightDataSource instead of claiming the unnamed
collectFlightData slot — additive, so a router's own flight data could
coexist on the same mutation response.

Co-authored-by: Cursor <cursoragent@cursor.com>
…rimitive; route cache redirects

The collector becomes loadFlightTarget (the router's trigger) +
dehydrateSettled (the cache's extraction), replacing the hand-rolled
event derivation and local settled() helper. The client boot gains the
last stretch of redirect glue: cache-driven fetches (background
refetches, mutations) run outside the router, so redirect() errors from
both caches now hand off to router.navigate — loader-driven redirects
were already the router's own on both sides.

Co-authored-by: Cursor <cursoragent@cursor.com>
// A fresh cache and router per collection — the same pairing SSR builds
// per request in src/setup.tsx, minus the render.
const queryClient = createQueryClient();
return loadFlightTarget({

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is pretty clean nice

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants