Merge pull request #1734 from PR0M3TH3AN/fix-nip07-init-retry-2139027211423598828

Retry NIP-07 extension detection to improve reliability
This commit is contained in:
thePR0M3TH3AN authored and GitHub committed 2026-01-26 09:39:01 -05:00
commit b248850aad
1 file changed
+28 -5
+28 -5
View File
@@ -3959,13 +3959,36 @@ export class NostrClient {
*/
async login(options = {}) {
try {
try {
await waitForNip07Extension();
} catch (waitError) {
devLogger.log("Timed out waiting for extension injection:", waitError);
let extension = null;
let attempts = 0;
const maxAttempts = 3;
while (!extension && attempts < maxAttempts) {
try {
await waitForNip07Extension();
extension = window.nostr;
} catch (waitError) {
devLogger.log(
`Timed out waiting for extension injection (attempt ${
attempts + 1
}/${maxAttempts}):`,
waitError,
);
}
if (extension) {
break;
}
attempts++;
if (attempts < maxAttempts) {
devLogger.log("Retrying NIP-07 detection...");
await new Promise((resolve) => setTimeout(resolve, 1000));
}
}
const extension = window.nostr;
extension = window.nostr;
if (!extension) {
devLogger.log("No Nostr extension found");
throw new Error(