Add detailed debug logging for query performance tracking

Added comprehensive debug logging to track query performance:
- EventStore: Log filter details and duration for each query
- useAuthor: Log query duration and whether profile was found
- NostrProvider: Log event count from each relay

This will help identify where delays are occurring:
- Are queries fast but waiting for network?
- Is IndexedDB slow?
- Are profiles missing from cache?

Co-authored-by: shakespeare.diy <assistant@shakespeare.diy>
This commit is contained in:
shakespeare.diy
2026-02-17 23:48:19 -06:00
parent b50e7bfe34
commit 29391cbe66
2 changed files with 14 additions and 1 deletions
+5
View File
@@ -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
});
}
+9 -1
View File
@@ -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);
}
};