Skip to content

fix(assets-controller): avoid race between ws message and AccountsAPI call - #10030

Open
Kriys94 wants to merge 1 commit into
mainfrom
fix/RaceWSAccountsAPI
Open

fix(assets-controller): avoid race between ws message and AccountsAPI call#10030
Kriys94 wants to merge 1 commit into
mainfrom
fix/RaceWSAccountsAPI

Conversation

@Kriys94

@Kriys94 Kriys94 commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Explanation

Current behavior: WS events were racing with TransactionController:transactionConfirmed events. If the AccountsAPI is not updated on time and return wrong response (eg due to cache), then the UI might display wrong balances.
https://www.loom.com/share/f17458c8da2c48efa4e9cfca9bab79e8

New Behavior: Fully rely on WS message when the chain is active with Websocket
https://www.loom.com/share/19a56758f6804f569ee60f1b825b5ff6

References

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them

Note

Medium Risk
Changes when balances refresh after transactions on WS-enabled chains; wrong gating could leave stale balances or skip needed pre-confirm updates on non-WS chains.

Overview
Stops transaction-driven force getAssets refreshes on chains where AccountActivity already pushes live WebSocket balance updates, so Accounts API/cache responses no longer race ahead of WS and overwrite correct balances in the UI.

#onUnapprovedTransactionAdded and #onTransactionConfirmed are merged into #refreshAssetsForTransaction, which still force-refreshes the sender’s account on that chain when AccountActivity is not active (e.g. gas estimation on unapproved txs). Tests cover unapproved-tx refresh and the no-op path after AccountActivityService:statusChanged marks the chain active.

Reviewed by Cursor Bugbot for commit 4961a5b. Bugbot is set up for automated code reviews on this repo. Configure here.

@Kriys94 Kriys94 changed the title fix(assets-controller): avoid race between ws message and AccountsAPI… fix(assets-controller): avoid race between ws message and AccountsAPI call Aug 31, 2026
@Kriys94
Kriys94 force-pushed the fix/RaceWSAccountsAPI branch from 9eb938b to 4961a5b Compare August 31, 2026 16:33
@Kriys94
Kriys94 marked this pull request as ready for review August 31, 2026 16:40
@Kriys94
Kriys94 requested a review from a team as a code owner August 31, 2026 16:40
@Kriys94
Kriys94 deployed to default-branch August 31, 2026 16:40 — with GitHub Actions Active
@salimtb

salimtb commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

@Kriys94 any reason why you're not adding something to the changelog md file ?

forceUpdate: true,
}).catch((error) => {
log('Failed to refresh assets after transaction confirmed', { error });
log('Failed to refresh assets after transaction event', { error });

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good one on renaming this

@juanmigdr juanmigdr left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Missing changelog and wondering what happens if WS is off or not working

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants