From 8d7d7a86cfafa1ca0cdb4cb78e2a4138f05deb81 Mon Sep 17 00:00:00 2001 From: thePR0M3TH3AN <53631862+PR0M3TH3AN@users.noreply.github.com> Date: Tue, 30 Sep 2025 16:22:50 -0400 Subject: [PATCH] Fix NIP-07 timeout helper to preserve user gestures --- js/nostr.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/js/nostr.js b/js/nostr.js index 9c92585f..c0043c40 100644 --- a/js/nostr.js +++ b/js/nostr.js @@ -62,10 +62,19 @@ function withNip07Timeout(operation) { }, NIP07_LOGIN_TIMEOUT_MS); }); - return Promise.race([ - Promise.resolve().then(operation), - timeoutPromise, - ]).finally(() => { + let operationResult; + try { + operationResult = operation(); + } catch (err) { + if (timeoutId) { + clearTimeout(timeoutId); + } + throw err; + } + + const operationPromise = Promise.resolve(operationResult); + + return Promise.race([operationPromise, timeoutPromise]).finally(() => { if (timeoutId) { clearTimeout(timeoutId); }