diff --git a/wallets/web3auth/src/extension/utils.ts b/wallets/web3auth/src/extension/utils.ts index 01842bcf9..d813a54b3 100644 --- a/wallets/web3auth/src/extension/utils.ts +++ b/wallets/web3auth/src/extension/utils.ts @@ -49,6 +49,7 @@ export const listenOnce = ( try { remove = await callback(data); } catch (error) { + console.error(error); remove = true; } @@ -57,7 +58,6 @@ export const listenOnce = ( removeEventListener?.call(worker, 'message', listener as any); } }; - // eslint-disable-next-line @typescript-eslint/no-explicit-any addEventListener?.call(worker, 'message', listener as any); }; @@ -126,6 +126,7 @@ export const connectClientAndProvider = async ( chainId: 'other', rpcTarget: 'other', displayName: 'other', + blockExplorer: 'other', ticker: 'other', tickerName: 'other', ...options.client.chainConfig, @@ -170,12 +171,25 @@ export const connectClientAndProvider = async ( let provider = client.connected ? client.provider : null; if (!client.connected && !dontAttemptLogin) { - const loginHint = options.getLoginHint?.(); - - provider = await client.connectTo(WALLET_ADAPTERS.OPENLOGIN, { - loginProvider: options.loginProvider, - login_hint: loginHint, - } as OpenloginLoginParams); + try { + const loginHint = options.getLoginHint?.(); + provider = await client.connectTo(WALLET_ADAPTERS.OPENLOGIN, { + loginProvider: options.loginProvider, + login_hint: loginHint, + } as OpenloginLoginParams); + } catch (err) { + // Unnecessary error thrown during redirect, so log and ignore it. + if ( + usingRedirect && + err instanceof Error && + err.message.includes('null') + ) { + console.error(err); + } else { + // Rethrow all other relevant errors. + throw err; + } + } } if (usingRedirect) {