Compare commits

...

2 Commits

Author SHA1 Message Date
yyh
e62b9ec8ce Merge branch 'main' into fix/query-client-infra-improvements 2026-02-23 18:16:02 +08:00
yyh
97417d7895 fix: improve TanStack Query client setup and fix queryKey bug
- Fix double-nested queryKey array in usePluginManifestInfo that broke
  invalidateQueries prefix matching
- Remove unnecessary useState in TanstackQueryInitializer per Advanced SSR guide
  https://tanstack.com/query/v5/docs/framework/react/guides/advanced-ssr#initial-setup
- Reduce default staleTime from 30min to 5min (matching gcTime default)
- Fix nuqs SearchParams import to use nuqs/server for consistency
2026-02-19 23:16:15 +08:00
4 changed files with 5 additions and 7 deletions

View File

@@ -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'

View File

@@ -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({

View File

@@ -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<PropsWithChildren> = ({ children }) => {
const [queryClient] = useState(getQueryClient)
export const TanstackQueryInitializer = ({ children }: { children: React.ReactNode }) => {
const queryClient = getQueryClient()
return (
<QueryClientProvider client={queryClient}>
{children}

View File

@@ -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,
})