Skip to content

Commit 9664714

Browse files
committed
Timeouts waiting for value as WC doesn't resolve
1 parent 484e6c5 commit 9664714

File tree

2 files changed

+21
-7
lines changed

2 files changed

+21
-7
lines changed

src/modules/check/connect.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,24 @@ function connect(
1313
} = {}
1414
): WalletCheckModule {
1515
const { heading, description, icon } = options
16-
16+
console.log('inside connect module')
1717
return async (
1818
stateAndHelpers: StateAndHelpers
1919
): Promise<WalletCheckModal | undefined> => {
2020
const { wallet, address, stateSyncStatus, stateStore } = stateAndHelpers
2121
if (address === null) {
2222
// wait for address sync if is still on initial value
2323
if (stateSyncStatus.address) {
24-
try {
25-
await stateSyncStatus.address
26-
} catch (error) {}
24+
await new Promise(resolve => {
25+
stateSyncStatus.address && stateSyncStatus.address.then(resolve)
26+
27+
setTimeout(() => {
28+
if (address === null) {
29+
// if prom isn't resolving after 250ms, then stop waiting
30+
resolve()
31+
}
32+
}, 250)
33+
})
2734
}
2835
}
2936

src/modules/check/network.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,16 @@ function network(
2424
if (network === null) {
2525
// wait for network sync if is still on initial value
2626
if (stateSyncStatus.network) {
27-
try {
28-
await stateSyncStatus.network
29-
} catch (error) {}
27+
await new Promise(resolve => {
28+
stateSyncStatus.network && stateSyncStatus.network.then(resolve)
29+
30+
setTimeout(() => {
31+
if (network === null) {
32+
// if prom isn't resolving after 250ms, then stop waiting
33+
resolve()
34+
}
35+
}, 250)
36+
})
3037
}
3138
}
3239

0 commit comments

Comments
 (0)