diff --git a/src/hooks/useAuthor.ts b/src/hooks/useAuthor.ts index 9c63cee1..103368b4 100644 --- a/src/hooks/useAuthor.ts +++ b/src/hooks/useAuthor.ts @@ -12,10 +12,14 @@ export function useAuthor(pubkey: string | undefined) { return {}; } + const queryStart = performance.now(); const [event] = await nostr.query( [{ kinds: [0], authors: [pubkey!], limit: 1 }], { signal: AbortSignal.any([signal, AbortSignal.timeout(1500)]) }, ); + const queryDuration = performance.now() - queryStart; + + console.debug(`[useAuthor] Query for ${pubkey.substring(0, 8)}... took ${queryDuration.toFixed(2)}ms, found: ${!!event}`); if (!event) { // Return empty object instead of throwing - profile doesn't exist or isn't cached yet @@ -30,6 +34,7 @@ export function useAuthor(pubkey: string | undefined) { } }, staleTime: 5 * 60 * 1000, // Keep cached data fresh for 5 minutes + gcTime: Infinity, // Never garbage collect - profiles are small and useful to keep retry: false, // Don't retry - if profile isn't found, it just doesn't exist }); } diff --git a/src/lib/eventStore.ts b/src/lib/eventStore.ts index 27c06a3f..71b62d98 100644 --- a/src/lib/eventStore.ts +++ b/src/lib/eventStore.ts @@ -141,7 +141,15 @@ class EventStore { const checkComplete = () => { if (pendingOperations === 0 && !hasError) { const duration = performance.now() - startTime; - console.debug(`[EventStore] Query completed in ${duration.toFixed(2)}ms, ${allEvents.length} events found`); + const filterDesc = filters.map(f => { + const parts = []; + if (f.kinds) parts.push(`kinds:${f.kinds.join(',')}`); + if (f.authors) parts.push(`authors:${f.authors.length}`); + if (f.ids) parts.push(`ids:${f.ids.length}`); + if (f.limit) parts.push(`limit:${f.limit}`); + return parts.join(' '); + }).join(' | '); + console.debug(`[EventStore] Query [${filterDesc}] completed in ${duration.toFixed(2)}ms, found ${allEvents.length} events`); this.finalizeQueryResults(allEvents, filters[0]?.limit, resolve); } };