Skip to content

Commit e574114

Browse files
[SDK] Don't retry on user connection rejection in EIP1193 connector (#6712)
1 parent aa733b7 commit e574114

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

.changeset/tall-terms-slide.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"thirdweb": patch
3+
---
4+
5+
Dont retry on user connection rejection in eip1193 connector

packages/thirdweb/src/wallets/injected/index.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ export async function connectEip1193Wallet({
6363
});
6464
} catch (e) {
6565
console.error(e);
66+
if (extractErrorMessage(e)?.toLowerCase()?.includes("rejected")) {
67+
throw e;
68+
}
6669
await new Promise((resolve) => setTimeout(resolve, 500));
6770
}
6871
attempts++;
@@ -375,3 +378,16 @@ async function switchChain(provider: EIP1193Provider, chain: Chain) {
375378
});
376379
}
377380
}
381+
382+
function extractErrorMessage(e: unknown) {
383+
if (e instanceof Error) {
384+
return e.message;
385+
}
386+
if (typeof e === "string") {
387+
return e;
388+
}
389+
if (typeof e === "object" && e !== null) {
390+
return JSON.stringify(e);
391+
}
392+
return String(e);
393+
}

0 commit comments

Comments
 (0)