fix: increase relay query timeouts and fix AppConfigSchema for cold mobile loads

- 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 <assistant@shakespeare.diy>
This commit is contained in:
shakespeare.diy 2026-06-18 15:28:26 +07:00
parent 9ed2c12de1
commit 72cb690e64
4 changed files with 6 additions and 5 deletions

View file

@ -25,7 +25,8 @@ const RelayMetadataSchema = z.object({
const AppConfigSchema = z.object({
theme: z.enum(['dark', 'light', 'system']),
relayMetadata: RelayMetadataSchema,
}) satisfies z.ZodType<AppConfig>;
useSkateRelay: z.boolean().optional(),
}) satisfies z.ZodType<Partial<AppConfig>>;
export function AppProvider(props: AppProviderProps) {
const {

View file

@ -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...');

View file

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

View file

@ -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();