From 19115c558c6306cc76f71e5610b69913874a87ec Mon Sep 17 00:00:00 2001 From: thePR0M3TH3AN <53631862+PR0M3TH3AN@users.noreply.github.com> Date: Tue, 27 Jan 2026 16:51:08 -0500 Subject: [PATCH] Adjust list fetch timeouts --- js/nostr/client.js | 9 +++++++-- js/services/hashtagPreferencesService.js | 1 + js/subscriptions.js | 1 + js/userBlocks.js | 2 ++ 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/js/nostr/client.js b/js/nostr/client.js index a159a871..a7a7ac56 100644 --- a/js/nostr/client.js +++ b/js/nostr/client.js @@ -3549,6 +3549,7 @@ export class NostrClient { * @param {string} [params.dTag] - Optional d-tag for addressable events (NIP-33). * @param {string[]} [params.relayUrls] - List of relays to query. Defaults to client's configured relays. * @param {function} [params.fetchFn] - Custom fetch function (mocks or specialized logic). Defaults to `pool.list`. + * @param {number} [params.timeoutMs] - Optional per-relay timeout for list fetches; defaults to a higher list-friendly baseline. * @returns {Promise} Deduplicated list of events found across all relays. */ async fetchListIncrementally({ @@ -3558,6 +3559,7 @@ export class NostrClient { relayUrls, fetchFn, since, + timeoutMs = 10000, } = {}) { // Explanation: // Optimizes network usage by only fetching "new" events from each relay. @@ -3639,11 +3641,14 @@ export class NostrClient { doFullFetch = false; } + // Allow callers to override list fetch timeouts without changing non-list query behavior. + const listTimeoutMs = Number.isFinite(timeoutMs) && timeoutMs > 0 ? timeoutMs : 10000; + try { // Wrap fetch with a timeout to prevent hanging on slow relays let events = await withRequestTimeout( actualFetchFn(relayUrl, filter), - 4000, + listTimeoutMs, null, `Fetch from ${relayUrl} timed out` ); @@ -3678,7 +3683,7 @@ export class NostrClient { delete filter.since; const events = await withRequestTimeout( actualFetchFn(relayUrl, filter), - 4000, + listTimeoutMs, null, `Full fetch fallback from ${relayUrl} timed out` ); diff --git a/js/services/hashtagPreferencesService.js b/js/services/hashtagPreferencesService.js index f17ffd8e..bcc369d9 100644 --- a/js/services/hashtagPreferencesService.js +++ b/js/services/hashtagPreferencesService.js @@ -517,6 +517,7 @@ class HashtagPreferencesService { dTag: HASHTAG_IDENTIFIER, relayUrls: relays, since, + timeoutMs: 12000, }), ); diff --git a/js/subscriptions.js b/js/subscriptions.js index 620948a5..a4f13085 100644 --- a/js/subscriptions.js +++ b/js/subscriptions.js @@ -451,6 +451,7 @@ class SubscriptionsManager { dTag: SUBSCRIPTION_LIST_IDENTIFIER, relayUrls, since: shouldForceFullFetch ? 0 : undefined, + timeoutMs: 12000, }); // Also check session actor if different? diff --git a/js/userBlocks.js b/js/userBlocks.js index dc47f954..b097adea 100644 --- a/js/userBlocks.js +++ b/js/userBlocks.js @@ -1115,6 +1115,7 @@ class UserBlockListManager { pubkey: normalized, relayUrls: relays, since: fetchSince, + timeoutMs: 12000, }), nostrClient.fetchListIncrementally({ kind: 30002, @@ -1122,6 +1123,7 @@ class UserBlockListManager { dTag: BLOCK_LIST_IDENTIFIER, relayUrls: relays, since: fetchSince, + timeoutMs: 12000, }), ]);