A self-hostable bookmark-everything app (links, notes and images) with AI-based automatic tagging and full text search
fix: fix a memory leak caused by gcTime calls on the server (#3138)
Mohamed Bassemdae096641c30
diff --git a/apps/web/components/dashboard/bookmarks/TagsEditor.tsx b/apps/web/components/dashboard/bookmarks/TagsEditor.tsxindex 3db641e7..53cb4eee 100644--- a/apps/web/components/dashboard/bookmarks/TagsEditor.tsx+++ b/apps/web/components/dashboard/bookmarks/TagsEditor.tsx@@ -15,7 +15,7 @@ import {import { useClientConfig } from "@/lib/clientConfig";import { useTranslation } from "@/lib/i18n/client";import { cn } from "@/lib/utils";-import { keepPreviousData, useQuery } from "@tanstack/react-query";+import { isServer, keepPreviousData, useQuery } from "@tanstack/react-query";import { Command as CommandPrimitive } from "cmdk";import { Check, Loader2, Plus, Sparkles, X } from "lucide-react";@@ -114,7 +114,13 @@ export function TagsEditor({: ("ai" as const),})),placeholderData: keepPreviousData,- gcTime: inputValue.length > 0 ? 60_000 : 3_600_000,+ // A finite gcTime on the server schedules a timer that pins the+ // request's query cache in memory; keep the default (Infinity) there.+ gcTime: isServer+ ? Infinity+ : inputValue.length > 0+ ? 60_000+ : 3_600_000,},),);diff --git a/packages/shared-react/hooks/tags.ts b/packages/shared-react/hooks/tags.tsindex 150eea3e..0f92a1e4 100644--- a/packages/shared-react/hooks/tags.ts+++ b/packages/shared-react/hooks/tags.ts@@ -1,4 +1,5 @@import {+ isServer,keepPreviousData,useInfiniteQuery,useMutation,@@ -21,7 +22,9 @@ export function usePaginatedSearchTags(...api.tags.list.infiniteQueryOptions(input, {placeholderData: keepPreviousData,getNextPageParam: (lastPage) => lastPage.nextCursor,- gcTime: 60_000,+ // On the server, a finite gcTime schedules a timer that pins the+ // request's query cache in memory; leave it at the default (Infinity).+ gcTime: isServer ? Infinity : 60_000,}),select: (data) => ({tags: data.pages.flatMap((page) => page.tags),@@ -44,7 +47,11 @@ export function useTagAutocomplete<T = ZTagListResponse>(opts: {},{placeholderData: keepPreviousData,- gcTime: opts.nameContains?.length > 0 ? 60_000 : 3_600_000,+ gcTime: isServer+ ? Infinity+ : opts.nameContains?.length > 0+ ? 60_000+ : 3_600_000,enabled: opts.enabled,},),