File tree Expand file tree Collapse file tree 2 files changed +10
-4
lines changed Expand file tree Collapse file tree 2 files changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -5,8 +5,7 @@ import { DomainReportView } from "@/components/domain/domain-report-view";
55import { analytics } from "@/lib/analytics/server" ;
66import { normalizeDomainInput } from "@/lib/domain" ;
77import { toRegistrableDomain } from "@/lib/domain-server" ;
8- import { makeQueryClient } from "@/trpc/query-client" ;
9- import { trpc } from "@/trpc/server" ;
8+ import { getQueryClient , trpc } from "@/trpc/server" ;
109
1110import "country-flag-icons/3x2/flags.css" ;
1211import "mapbox-gl/dist/mapbox-gl.css" ;
@@ -52,7 +51,8 @@ export default async function DomainPage({
5251 analytics . track ( "report_viewed" , { domain : normalized } ) ;
5352
5453 // Minimal prefetch: registration only, let sections stream progressively
55- const queryClient = makeQueryClient ( ) ;
54+ // Use getQueryClient() to ensure consistent query client across the request
55+ const queryClient = getQueryClient ( ) ;
5656 void queryClient . prefetchQuery (
5757 trpc . domain . registration . queryOptions ( { domain : normalized } ) ,
5858 ) ;
Original file line number Diff line number Diff line change 11import "server-only" ;
22
33import { createTRPCOptionsProxy } from "@trpc/tanstack-react-query" ;
4+ import { cache } from "react" ;
45import { appRouter } from "@/server/routers/_app" ;
56import { createContext } from "@/trpc/init" ;
67import { makeQueryClient } from "@/trpc/query-client" ;
78
9+ // Create a stable getter for the query client that will return the same client during
10+ // the same request. This ensures consistent query client behavior across multiple tRPC
11+ // calls within a single server request.
12+ export const getQueryClient = cache ( makeQueryClient ) ;
13+
814// Strongly-typed tRPC proxy for server-side prefetching via queryOptions
915export const trpc = createTRPCOptionsProxy ( {
1016 ctx : createContext ,
1117 router : appRouter ,
12- queryClient : makeQueryClient ,
18+ queryClient : getQueryClient ,
1319} ) ;
You can’t perform that action at this time.
0 commit comments