From aebb667d1c092ec1546f0b011e6c61fbcf163b09 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Tue, 10 Feb 2026 00:28:27 +0000 Subject: [PATCH] fix(ai): prevent test timeouts in subscriptions (agent) suggested Co-authored-by: PR0M3TH3AN <53631862+PR0M3TH3AN@users.noreply.github.com> --- js/subscriptions.js | 15 ++++++++++----- tests/subscriptions-manager.test.mjs | 1 + 2 files changed, 11 insertions(+), 5 deletions(-) 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;