From 6a3db151a82a8d28b1a67c3494dabac852cd141a Mon Sep 17 00:00:00 2001 From: yyh <92089059+lyzno1@users.noreply.github.com> Date: Sun, 1 Mar 2026 16:32:42 +0800 Subject: [PATCH] fix: improve TanStack Query client setup and fix queryKey bug (#32422) --- web/app/components/plugins/marketplace/hydration-server.tsx | 2 +- web/context/query-client-server.ts | 2 +- web/context/query-client.tsx | 6 ++---- web/service/use-plugins.ts | 2 +- 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/web/app/components/plugins/marketplace/hydration-server.tsx b/web/app/components/plugins/marketplace/hydration-server.tsx index b01f4dd463..bf01f4d4ed 100644 --- a/web/app/components/plugins/marketplace/hydration-server.tsx +++ b/web/app/components/plugins/marketplace/hydration-server.tsx @@ -1,4 +1,4 @@ -import type { SearchParams } from 'nuqs' +import type { SearchParams } from 'nuqs/server' import { dehydrate, HydrationBoundary } from '@tanstack/react-query' import { createLoader } from 'nuqs/server' import { getQueryClientServer } from '@/context/query-client-server' diff --git a/web/context/query-client-server.ts b/web/context/query-client-server.ts index 3650e30f52..69bd29ae97 100644 --- a/web/context/query-client-server.ts +++ b/web/context/query-client-server.ts @@ -1,7 +1,7 @@ import { QueryClient } from '@tanstack/react-query' import { cache } from 'react' -const STALE_TIME = 1000 * 60 * 30 // 30 minutes +const STALE_TIME = 1000 * 60 * 5 // 5 minutes export function makeQueryClient() { return new QueryClient({ diff --git a/web/context/query-client.tsx b/web/context/query-client.tsx index 1cd64b168b..38292bfc8c 100644 --- a/web/context/query-client.tsx +++ b/web/context/query-client.tsx @@ -1,9 +1,7 @@ 'use client' import type { QueryClient } from '@tanstack/react-query' -import type { FC, PropsWithChildren } from 'react' import { QueryClientProvider } from '@tanstack/react-query' -import { useState } from 'react' import { TanStackDevtoolsLoader } from '@/app/components/devtools/tanstack/loader' import { isServer } from '@/utils/client' import { makeQueryClient } from './query-client-server' @@ -19,8 +17,8 @@ function getQueryClient() { return browserQueryClient } -export const TanstackQueryInitializer: FC = ({ children }) => { - const [queryClient] = useState(getQueryClient) +export const TanstackQueryInitializer = ({ children }: { children: React.ReactNode }) => { + const queryClient = getQueryClient() return ( {children} diff --git a/web/service/use-plugins.ts b/web/service/use-plugins.ts index 5267503a11..ea32cf8ab7 100644 --- a/web/service/use-plugins.ts +++ b/web/service/use-plugins.ts @@ -653,7 +653,7 @@ export const useMutationClearAllTaskPlugin = () => { export const usePluginManifestInfo = (pluginUID: string) => { return useQuery({ enabled: !!pluginUID, - queryKey: [[NAME_SPACE, 'manifest', pluginUID]], + queryKey: [NAME_SPACE, 'manifest', pluginUID], queryFn: () => getMarketplace<{ data: { plugin: PluginInfoFromMarketPlace, version: { version: string } } }>(`/plugins/${pluginUID}`), retry: 0, })