From 8a61acb09ced763ab85e5c67858599b14a152506 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Mon, 12 Jan 2026 00:10:04 +0000 Subject: [PATCH] Add debug logging to trace subscription loading hang --- js/feedEngine/sources.js | 7 +++++++ js/services/nostrService.js | 5 +++++ js/subscriptions.js | 8 ++++++++ 3 files changed, 20 insertions(+) diff --git a/js/feedEngine/sources.js b/js/feedEngine/sources.js index b8994fe7..bf7bf2a3 100644 --- a/js/feedEngine/sources.js +++ b/js/feedEngine/sources.js @@ -66,6 +66,7 @@ export function createSubscriptionAuthorsSource({ service } = {}) { const resolvedService = resolveService(service, nostrService); return async function subscriptionAuthorsSource(context = {}) { + context?.log?.("[subscriptions-source] START"); const runtimeAuthors = toArray( context?.runtime?.subscriptionAuthors || context?.runtime?.authors ).map(normalizeAuthor); @@ -88,6 +89,8 @@ export function createSubscriptionAuthorsSource({ service } = {}) { [...runtimeAuthors, ...configAuthors, ...hookAuthors].filter(Boolean) ); + context?.log?.(`[subscriptions-source] Resolved ${authors.size} authors.`); + if (!authors.size) { return []; } @@ -115,12 +118,16 @@ export function createSubscriptionAuthorsSource({ service } = {}) { let videos = []; try { if (hasTargetedLookup) { + context?.log?.("[subscriptions-source] Calling getActiveVideosByAuthors..."); videos = await Promise.resolve( resolvedService.getActiveVideosByAuthors(authorList, options) ); + context?.log?.(`[subscriptions-source] getActiveVideosByAuthors returned ${videos.length} videos.`); if (!videos.length && typeof resolvedService.fetchVideosByAuthors === "function") { + context?.log?.("[subscriptions-source] Cache empty. Calling fetchVideosByAuthors..."); const fetched = await resolvedService.fetchVideosByAuthors(authorList, options); + context?.log?.(`[subscriptions-source] fetchVideosByAuthors returned ${fetched ? fetched.length : 0} videos.`); if (Array.isArray(fetched) && fetched.length > 0) { videos = fetched; } diff --git a/js/services/nostrService.js b/js/services/nostrService.js index 92ae53c8..7a5ea3f0 100644 --- a/js/services/nostrService.js +++ b/js/services/nostrService.js @@ -1176,6 +1176,8 @@ export class NostrService { return []; } + this.log(`[nostrService] fetchVideosByAuthors START. Authors: ${authorList.length}`); + const requestedLimit = Number(options?.limit); const resolvedLimit = this.nostrClient.clampVideoRequestLimit( requestedLimit @@ -1193,10 +1195,13 @@ export class NostrService { const invalidNotes = []; try { + this.log(`[nostrService] Querying ${this.nostrClient.relays.length} relays...`); await Promise.all( this.nostrClient.relays.map(async (url) => { try { + this.log(`[nostrService] Querying relay: ${url}`); const events = await this.nostrClient.pool.list([url], [filter]); + this.log(`[nostrService] Relay ${url} returned ${events.length} events.`); for (const evt of events) { if (evt && evt.id) { this.nostrClient.rawEvents.set(evt.id, evt); diff --git a/js/subscriptions.js b/js/subscriptions.js index 570c5343..b239274d 100644 --- a/js/subscriptions.js +++ b/js/subscriptions.js @@ -398,17 +398,20 @@ class SubscriptionsManager { } async ensureLoaded(actorHex) { + devLogger.log("[SubscriptionsManager] ensureLoaded start", actorHex); const normalizedActor = normalizeHexPubkey(actorHex) || actorHex; if (!normalizedActor) { return; } if (this.loaded && this.currentUserPubkey === normalizedActor) { + devLogger.log("[SubscriptionsManager] ensureLoaded already loaded"); return; } if (this.loadingPromise) { try { + devLogger.log("[SubscriptionsManager] ensureLoaded awaiting existing promise"); await this.loadingPromise; } catch (error) { throw error; @@ -431,6 +434,7 @@ class SubscriptionsManager { ) ), ]); + devLogger.log("[SubscriptionsManager] ensureLoaded success"); } catch (error) { userLogger.warn("[SubscriptionsManager] ensureLoaded timed out or failed:", error); } finally { @@ -870,7 +874,9 @@ class SubscriptionsManager { if (typeof nostrService?.awaitInitialLoad === "function") { try { + devLogger.log("[SubscriptionsManager] awaiting nostrService initial load..."); await nostrService.awaitInitialLoad(); + devLogger.log("[SubscriptionsManager] nostrService initial load done."); } catch (error) { devLogger.warn( "[SubscriptionsManager] Failed to await nostrService initial load:", @@ -906,7 +912,9 @@ class SubscriptionsManager { try { this.isRunningFeed = true; + devLogger.log("[SubscriptionsManager] Calling engine.run('subscriptions')..."); const result = await engine.run("subscriptions", runOptions); + devLogger.log("[SubscriptionsManager] engine.run complete. Items:", result?.items?.length); const videos = Array.isArray(result?.items) ? result.items.map((item) => item?.video).filter(Boolean)