From b0fcb0e897ed273816fa9abedfd56e869f48a95b Mon Sep 17 00:00:00 2001 From: Gigi Date: Sat, 18 Oct 2025 00:49:05 +0200 Subject: [PATCH] debug: add detailed logging to diagnose hydration hanging Added extensive logging to track queryEvents lifecycle: - Log when queryEvents is called - Log each event as it's received via onEvent callback - Log when batch completes with event count - Log errors if batch fails This will help identify where the hydration is hanging - whether: - queryEvents never returns - No events are received - Some batches fail silently No functional changes, only diagnostic logging. --- src/services/bookmarkController.ts | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/services/bookmarkController.ts b/src/services/bookmarkController.ts index e29681f4..b9bc9987 100644 --- a/src/services/bookmarkController.ts +++ b/src/services/bookmarkController.ts @@ -152,13 +152,16 @@ class BookmarkController { const batch = batches[i] console.log('[bookmark] 🔧 Fetching batch', i + 1, '/', batches.length, '(', batch.length, 'IDs )') + console.log('[bookmark] 🔧 First few IDs in batch:', batch.slice(0, 3)) try { + console.log('[bookmark] 🔧 Calling queryEvents...') const events = await queryEvents( relayPool, { ids: batch }, { onEvent: (e: NostrEvent) => { + console.log('[bookmark] 📨 Received event:', e.id.slice(0, 8), 'kind:', e.kind) idToEvent.set(e.id, e) // Also index by coordinate for addressable events if (e.kind && e.kind >= 30000 && e.kind < 40000) { @@ -170,9 +173,9 @@ class BookmarkController { } } ) - console.log('[bookmark] ✅ Batch', i + 1, 'fetched', events.length, 'events') + console.log('[bookmark] ✅ Batch', i + 1, 'completed with', events.length, 'events') } catch (error) { - console.warn('[bookmark] ⚠️ Batch', i + 1, 'failed:', error) + console.error('[bookmark] ❌ Batch', i + 1, 'failed:', error) } } } @@ -222,12 +225,16 @@ class BookmarkController { return } + console.log('[bookmark] 🔧 Fetching kind', kind, ':', authorBatch.length, 'authors ×', idBatch.length, 'identifiers') + try { + console.log('[bookmark] 🔧 Calling queryEvents for coordinates...') const events = await queryEvents( relayPool, { kinds: [kind], authors: authorBatch, '#d': idBatch }, { onEvent: (e: NostrEvent) => { + console.log('[bookmark] 📨 Received coordinate event:', e.id.slice(0, 8), 'kind:', e.kind) const dTag = e.tags?.find((t: string[]) => t[0] === 'd')?.[1] || '' const coordinate = `${e.kind}:${e.pubkey}:${dTag}` idToEvent.set(coordinate, e) @@ -236,9 +243,9 @@ class BookmarkController { } } ) - console.log('[bookmark] ✅ Kind', kind, 'batch fetched', events.length, 'events') + console.log('[bookmark] ✅ Kind', kind, 'batch completed with', events.length, 'events') } catch (error) { - console.warn('[bookmark] ⚠️ Kind', kind, 'batch failed:', error) + console.error('[bookmark] ❌ Kind', kind, 'batch failed:', error) } } }