Skip to content

Commit

Permalink
fix: retries
Browse files Browse the repository at this point in the history
  • Loading branch information
IsaccoSordo committed Aug 12, 2024
1 parent 2b1a2d7 commit 764ce9f
Showing 1 changed file with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -542,8 +542,6 @@ export class WalletConnectCommunicationClient extends CommunicationClient {
const signClient = await this.getSignClient()

if (!signClient) {
const fun = this.eventHandlers.get(ClientEvents.CLOSE_ALERT)
fun && fun()
throw new Error('Failed to connect to the relayer.')
}

Expand Down Expand Up @@ -1317,22 +1315,23 @@ export class WalletConnectCommunicationClient extends CommunicationClient {
}

private async tryConnectToRelayer() {
const urls = [
const urls = new Set([
this.wcOptions.opts.relayUrl,
undefined,
'wss://relay.walletconnect.com',
'wss://relay.walletconnect.org'
]
let errMessages = []
])
let errMessages = new Set()

for (const relayUrl of urls) {
try {
return await Client.init({ ...this.wcOptions.opts, relayUrl })
} catch (err: any) {
errMessages.push(err.message)
errMessages.add(err.message)
logger.warn(`Failed to connect to ${relayUrl}: ${err.message}`)
}
}
throw new Error(`Failed to connect to relayer: ${errMessages.join(',').slice(0, -1)}`)
throw new Error(`Failed to connect to relayer: ${Array.from(errMessages).join(',')}`)
}

private async getSignClient(): Promise<Client | undefined> {
Expand Down

0 comments on commit 764ce9f

Please sign in to comment.