Skip to content

Commit 0bce372

Browse files
committed
fix(core): refresh wallet state after async subscription call
The result processing loop was using stale wallet data captured in indexToWalletId before the await.
1 parent f789167 commit 0bce372

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

src/core/currency/currency-pixie.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,11 +302,18 @@ export const currency: TamePixie<RootProps> = combinePixies({
302302
subscriptionTimeoutId = undefined
303303
}
304304

305+
// Refresh state to avoid using stale wallet data after the await:
306+
const { wallets: freshWallets } = input.props.state.currency
307+
305308
const subscriptionUpdates: Map<string, ChangeServiceSubscription[]> =
306309
new Map()
307310
for (let i = 0; i < results.length; i++) {
308311
const result = results[i]
309-
const { walletId, wallet } = indexToWalletId[i]
312+
const { walletId } = indexToWalletId[i]
313+
const wallet = freshWallets[walletId]
314+
315+
// Skip if wallet was removed during await:
316+
if (wallet == null) continue
310317

311318
// Determine the new status of the subscription to all addresses
312319
// for the wallet:

0 commit comments

Comments
 (0)