diff --git a/js/nostr/client.js b/js/nostr/client.js index 1ab71bac..2b7e5ae3 100644 --- a/js/nostr/client.js +++ b/js/nostr/client.js @@ -2079,7 +2079,7 @@ export class NostrClient { } const permissionResult = await this.ensureExtensionPermissions( - DEFAULT_NIP07_CORE_METHODS, + DEFAULT_NIP07_PERMISSION_METHODS, { context: "login", logMetrics: true, showStatus: false }, ); if (!permissionResult.ok) { diff --git a/js/services/hashtagPreferencesService.js b/js/services/hashtagPreferencesService.js index bc481a51..28ef0d40 100644 --- a/js/services/hashtagPreferencesService.js +++ b/js/services/hashtagPreferencesService.js @@ -775,19 +775,22 @@ class HashtagPreferencesService { const decryptPromise = this.decryptEvent(latest, normalized, { allowPermissionPrompt, }); - const timeoutPromise = new Promise((_, reject) => - setTimeout( - () => { - const timeoutError = new Error( - `Decryption timed out after ${DECRYPT_TIMEOUT_MS / 1000}s`, - ); - timeoutError.code = "hashtag-preferences-decrypt-timeout"; - reject(timeoutError); - }, - DECRYPT_TIMEOUT_MS, - ), - ); - decryptResult = await Promise.race([decryptPromise, timeoutPromise]); + let timeoutId; + const timeoutPromise = new Promise((_, reject) => { + timeoutId = setTimeout(() => { + const timeoutError = new Error( + `Decryption timed out after ${DECRYPT_TIMEOUT_MS / 1000}s`, + ); + timeoutError.code = "hashtag-preferences-decrypt-timeout"; + reject(timeoutError); + }, DECRYPT_TIMEOUT_MS); + }); + + try { + decryptResult = await Promise.race([decryptPromise, timeoutPromise]); + } finally { + if (timeoutId) clearTimeout(timeoutId); + } } catch (error) { decryptResult = { ok: false, error }; } diff --git a/tests/hashtag-preferences.test.mjs b/tests/hashtag-preferences.test.mjs index f72827cd..afd68da7 100644 --- a/tests/hashtag-preferences.test.mjs +++ b/tests/hashtag-preferences.test.mjs @@ -248,10 +248,8 @@ test( tags: [["encrypted", "nip04"]], }; - let fetchCalls = 0; nostrClient.fetchListIncrementally = async () => { - fetchCalls += 1; - return fetchCalls === 1 ? [event] : []; + return [event]; }; nostrClient.relays = relayUrls; nostrClient.writeRelays = relayUrls;