Skip to content

Commit

Permalink
rescuing timeout on balace request
Browse files Browse the repository at this point in the history
  • Loading branch information
julien51 committed Jul 20, 2023
1 parent 728737f commit 447c118
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions locksmith/src/fulfillment/dispatcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,19 @@ export default class Dispatcher {
Object.values(networks).map(async (network: any) => {
try {
const { wallet, provider } = await this.getPurchaser(network.id)
const balance = await provider.getBalance(wallet.address)

const balance: ethers.BigNumberish =
await Promise.race<ethers.BigNumberish>([
new Promise((resolve) =>
setTimeout(() => {
console.log(
`Could not retrieve balance on network ${network.id}`
)
resolve(0)
}, 3000)
),
provider.getBalance(wallet.address),
])
return [
network.id,
{
Expand All @@ -62,7 +74,10 @@ export default class Dispatcher {
},
]
} catch (error) {
logger.error(error)
logger.error('Could not retrieve balance on network', {
network,
error,
})
return [network.id, {}]
}
})
Expand Down

0 comments on commit 447c118

Please sign in to comment.