Skip to content

Prepare for TanStack Query v6 - #750

Open
sandhose wants to merge 6 commits into
mainfrom
quenting/tanstack-query-v6-prep
Open

sandhose wants to merge 6 commits into
mainfrom
quenting/tanstack-query-v6-prep

Conversation

@sandhose

@sandhose sandhose commented Nov 22, 2026 •

Copy link
Copy Markdown
Member

Adopts the parts of the TanStack Query v6 roadmap that already work on 5.x, so the eventual upgrade is a version bump. Best reviewed commit by commit.

Imperative query methods

v6 removes ensureQueryData, ensureInfiniteQueryData and prefetchQuery, all already deprecated. The 80 call sites move to queryClient.query() / infiniteQuery():

  • ensureQueryData(opts) → query({ ...opts, staleTime: "static" }). Without "static", loaders would block on refetching data older than the default stale time instead of returning the cache.
  • prefetchQuery(opts) → query(opts).catch(noop). prefetchQuery never rejected, and some loaders rely on that for optional endpoints.

typescript/no-deprecated is now an error so these can't come back. Enabling it also flagged React's deprecated FormEvent (now SubmitEvent / InputEvent) and a deprecated field in the MAS site-config mock that nothing reads.

enabled → skipToken

Upstream is still discussing whether enabled gets removed, but where a query's inputs may be missing, making the query function exist only once they do removes the || "" placeholder arguments.

  • mediaThumbnailQuery already took an optional mxc, so it skips inside the factory.
  • The personal token page renders the owner-dependent regenerate button in a child component that only mounts when the token has an owner.
  • room-info.tsx had all inputs present and just didn't always want the data. It now renders conditionally: unnamed rooms mount components that always fetch the members, named rooms never do.

The login page keeps enabled on its three chained discovery queries. Each depends on the previous one's result and the page shows a per-step error from the first failed attempt; the alternatives tried (one query chaining the steps, serial suspense queries) were either awkward or lost that feedback. It can be revisited once upstream settles.

Query keys are unchanged.

Browserslist

.browserslistrc has had no consumer since browserslist-to-esbuild and eslint-plugin-compat were removed, so it goes away along with its script and direct dependency.

Synapse root in the route context

Not required by v6, but it removes most of the remaining well-known plumbing. _console's beforeLoad awaits the well-known once and exposes synapseRoot in the route context; loaders and route components read it from there, and the shared user cells and cards take it as a prop. wellKnownQuery goes from 33 call sites to 6, the ones that run outside the _console context (login, callback, token refresh, MAS query functions, the root error page).

A failing well-known still ends on the same error page with the sign-out option. The console layout keeps a useQuery observer on the well-known so it stays in memory for the whole session, as it did when the layout read it with useSuspenseQuery.

TanStack Query v6 removes ensureQueryData, ensureInfiniteQueryData and prefetchQuery, which are already deprecated in 5.x.

The ensure* calls become query()/infiniteQuery() with staleTime: "static", so loaders keep returning cached data instead of refetching it once it is older than the client's default stale time.

The prefetchQuery calls become query().catch(noop): prefetchQuery never rejected, and some loaders rely on that to not fail when an optional endpoint errors.
@types/react deprecates FormEvent since it doesn't map to a real event type: form submit handlers now take SubmitEvent, and the room search input handler takes InputEvent.

The MAS site-config mock no longer sets registration_token_required. It is deprecated in favour of password_registration_token_required, optional in the API type, and nothing in the app reads it.
Catches deprecated APIs ahead of major upgrades, such as the TanStack Query methods removed in v6.
Nothing reads .browserslistrc since browserslist-to-esbuild and eslint-plugin-compat were removed, so the config file, the helper script and the direct dependency only add noise. browserslist stays as a transitive dependency.
@sandhose sandhose added the T-Task Refactoring, removal, replacement, enabling or disabling functionality, other engineering tasks. label Nov 22, 2026
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

Deploying admin-beta-element-dev with  Cloudflare Pages  Cloudflare Pages

Latest commit: 3d8618e
Status: ✅  Deploy successful!
Preview URL: https://7fcac542.admin-beta-element-dev.pages.dev
Branch Preview URL: https://quenting-tanstack-query-v6-p.admin-beta-element-dev.pages.dev

View logs

@sandhose
sandhose force-pushed the quenting/tanstack-query-v6-prep branch 3 times, most recently from b5e037b to ae3ce04 Compare November 23, 2026 10:18
TanStack Query v6 plans to drop `enabled` in favour of `skipToken`, which makes the query function exist only once its inputs do, so no placeholder arguments are needed to satisfy the types.

mediaThumbnailQuery already takes an optional mxc, and skips the query itself when there is none.

The personal token page renders the owner-dependent regenerate button in a child component that only mounts when the token has an owner, and passes the owner ID straight to its user card.

The room info components replace their conditionally enabled members query with conditional rendering: unnamed rooms render components that always fetch the members, and named rooms never mount them.

The login page keeps `enabled` on its three chained discovery queries: each depends on the previous one's result, and the page shows a per-step error from the first failed attempt.
Every loader and component under _console rediscovered the homeserver base URL through the well-known query, and shared cells and cards took a server name only to do the same. The _console beforeLoad now awaits the well-known after the login guard and exposes synapseRoot in the route context, so loaders and components read it from there and shared components take it as a prop.
@sandhose
sandhose force-pushed the quenting/tanstack-query-v6-prep branch from ae3ce04 to 3d8618e Compare November 23, 2026 10:40

This branch has not been deployed

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

Labels

T-Task Refactoring, removal, replacement, enabling or disabling functionality, other engineering tasks.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant