diff --git a/js/subscriptions.js b/js/subscriptions.js index 33f41651..fd43fe6d 100644 --- a/js/subscriptions.js +++ b/js/subscriptions.js @@ -913,15 +913,20 @@ class SubscriptionsManager { // scheme × up to 3 schemes = ~18s) = ~30s. Reduced from 45s to prevent // blocking the login path for nearly a minute. const timeoutMs = 25000; + let timeoutId; await Promise.race([ loader, - new Promise((_, reject) => - setTimeout( + new Promise((_, reject) => { + timeoutId = setTimeout( () => reject(new Error("Timeout loading subscriptions")), timeoutMs - ) - ), - ]); + ); + }), + ]).finally(() => { + if (timeoutId) { + clearTimeout(timeoutId); + } + }); devLogger.log("[SubscriptionsManager] ensureLoaded success"); return { ok: this.dataReady === true, error: this.lastLoadError || null, state: this.getLoadState() }; } catch (error) { diff --git a/tests/subscriptions-manager.test.mjs b/tests/subscriptions-manager.test.mjs index 2e913690..3b159587 100644 --- a/tests/subscriptions-manager.test.mjs +++ b/tests/subscriptions-manager.test.mjs @@ -619,6 +619,7 @@ test( "retry with permission prompts should populate subscriptions", ); } finally { + manager.reset(); relayManager.setEntries(originalRelayEntries, { allowEmpty: false, updateClient: false }); nostrClient.relays = originalRelays; nostrClient.writeRelays = originalWriteRelays;