Add debug logging to trace subscription loading hang

This commit is contained in:
google-labs-jules[bot] committed 2026-01-12 00:10:04 +00:00
1 parent fdf8815792
commit 8a61acb09c
3 files changed
+20

No files matched your search

+7
View File
@@ -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;
}
+5
View File
@@ -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);
+8
View File
@@ -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)