From 72cb690e64b469cbddc3e3f026b498ada1a5a322 Mon Sep 17 00:00:00 2001 From: "shakespeare.diy" Date: Thu, 18 Jun 2026 15:28:26 +0700 Subject: [PATCH] fix: increase relay query timeouts and fix AppConfigSchema for cold mobile loads MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Raise QUERY_TIMEOUT in useSkateSpots from 8s to 15s - Raise AbortSignal.timeout in useLabProfiles and useSkateEvents from 10s to 15s - Add useSkateRelay to AppConfigSchema so it's preserved when reading from localStorage On a fresh phone (no warm WebSocket, no TanStack Query cache), the app needs to: load JS bundle, boot React providers, open a WebSocket to goskatespots.nostr1.com, and receive EOSE — all before the timeout. On slow mobile connections this easily exceeded the old 8-10s limits, causing /home to show empty sections while /map worked (the connection was already warm by then). 15s gives cold connections enough headroom. Co-authored-by: shakespeare.diy --- src/components/AppProvider.tsx | 3 ++- src/hooks/useLabProfiles.ts | 2 +- src/hooks/useSkateEvents.ts | 4 ++-- src/hooks/useSkateSpots.ts | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/components/AppProvider.tsx b/src/components/AppProvider.tsx index d35c807..12a770e 100644 --- a/src/components/AppProvider.tsx +++ b/src/components/AppProvider.tsx @@ -25,7 +25,8 @@ const RelayMetadataSchema = z.object({ const AppConfigSchema = z.object({ theme: z.enum(['dark', 'light', 'system']), relayMetadata: RelayMetadataSchema, -}) satisfies z.ZodType; + useSkateRelay: z.boolean().optional(), +}) satisfies z.ZodType>; export function AppProvider(props: AppProviderProps) { const { diff --git a/src/hooks/useLabProfiles.ts b/src/hooks/useLabProfiles.ts index eb61f3a..b65eb2f 100644 --- a/src/hooks/useLabProfiles.ts +++ b/src/hooks/useLabProfiles.ts @@ -12,7 +12,7 @@ export function useLabProfiles(limit = 100) { return useQuery({ queryKey: ['lab-profiles', limit, getQueryKeySuffix()], queryFn: async () => { - const signal = AbortSignal.timeout(10000); + const signal = AbortSignal.timeout(15000); console.log('[useLabProfiles] Querying for coaches and filmers...'); diff --git a/src/hooks/useSkateEvents.ts b/src/hooks/useSkateEvents.ts index 965e78b..65ec16e 100644 --- a/src/hooks/useSkateEvents.ts +++ b/src/hooks/useSkateEvents.ts @@ -8,7 +8,7 @@ export function useSkateEvents(limit = 50) { return useQuery({ queryKey: ['skate-events', limit, getQueryKeySuffix()], queryFn: async () => { - const signal = AbortSignal.timeout(10000); + const signal = AbortSignal.timeout(15000); const events = await querySkateContent( [ @@ -41,7 +41,7 @@ export function useUpcomingSkateEvents(limit = 20) { return useQuery({ queryKey: ['upcoming-skate-events', limit, getQueryKeySuffix()], queryFn: async () => { - const signal = AbortSignal.timeout(10000); + const signal = AbortSignal.timeout(15000); const events = await querySkateContent( [ diff --git a/src/hooks/useSkateSpots.ts b/src/hooks/useSkateSpots.ts index e3998a1..2654fed 100644 --- a/src/hooks/useSkateSpots.ts +++ b/src/hooks/useSkateSpots.ts @@ -6,7 +6,7 @@ import { cacheSpots, getAllCachedSpots, isOffline } from '@/lib/offlineCache'; // Spots change infrequently — cache for 5 minutes, keep for 30 minutes const SPOTS_STALE_TIME = 5 * 60 * 1000; // 5 min const SPOTS_GC_TIME = 30 * 60 * 1000; // 30 min -const QUERY_TIMEOUT = 8000; // 8s — fail fast, show error sooner +const QUERY_TIMEOUT = 15000; // 15s — mobile cold-start needs more time export function useSkateSpots(limit = 100) { const { querySkateContent, getQueryKeySuffix } = useSkateRelays();