fix: fix account api cache cp-8.8.0 - #34748
Conversation
|
CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes. |
PR template — items to address before "Ready for review"Warnings — informational, address before merging:
See docs/readme/ready-for-review.md for the full Definition of Ready for Review. |
Match core revert of #9591: forceUpdate balance fetches use staleTime/gcTime 0 again instead of the 100ms window.
Align with MetaMask/core#9867: invalidate balance queries and fetch with staleTime/gcTime 0 on every AccountsApiDataSource fetch.
Revert forceUpdate balance cache window from 100ms to staleTime/gcTime 0 so forced refreshes bypass TanStack cache (MetaMask/core#9870).
Retarget assets-controller forceUpdate cache patch from 13.1.2 to 13.1.3 (staleTime/gcTime 0 on forceUpdate) after main bump. Co-authored-by: Cursor <cursoragent@cursor.com>
🔍 Smart E2E Test Selection
click to see 🤖 AI reasoning detailsE2E Test Selection: Performance Test Selection: |
|
⚡ Performance Test Results
✅ All tests passed · 4 tests · 1 device 📱 Devices tested (1)Android: Google Pixel 8 Pro (v14.0) ✅ Passed Tests (4)
Branch: |
…ts api request (MetaMask#9591) (MetaMask#9870) This reverts commit 1b082f7. Extension PR: MetaMask/metamask-extension#45494 Mobile PR: MetaMask/metamask-mobile#34748 ## Explanation <!-- Thanks for your contribution! Take a moment to answer these questions so that reviewers have the information they need to properly understand your changes: * What is the current state of things and why does it need to change? * What is the solution your changes offer and how does it work? * Are there any changes whose purpose might not obvious to those unfamiliar with the domain? * If your primary goal was to update one package but you found you had to update another one along the way, why did you do so? * If you had to upgrade a dependency, why did you do so? --> ## References <!-- Are there any issues that this pull request is tied to? Are there other links that reviewers should consult to understand these changes better? Are there client or consumer pull requests to adopt any breaking changes? For example: * Fixes #12345 * Related to #67890 --> ## 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](https://github.com/MetaMask/core/tree/main/docs/processes/updating-changelogs.md) - [ ] I've introduced [breaking changes](https://github.com/MetaMask/core/tree/main/docs/processes/breaking-changes.md) in this PR and have prepared draft pull requests for clients and consumer packages to resolve them <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Touches balance refresh behavior on user-visible paths (force refresh); tradeoff is fresher balances vs slightly more Accounts API traffic, with low security impact. > > **Overview** > Reverts [MetaMask#9591](MetaMask#9591): when `AccountsApiDataSource` handles a balance fetch with **`forceUpdate: true`**, TanStack Query options go back to **`staleTime: 0` and `gcTime: 0`** instead of a 100ms window. > > Forced refreshes (e.g. after unlock, account/network changes, or explicit refresh) are meant to hit the Accounts API with a fresh request; the short cache window could reuse a just-fetched entry and leave balances stale. The unit test is renamed/updated to assert cache bypass on `forceUpdate`. > > The **Unreleased** changelog documents this revert; it also consolidates the Arc native USDC default-tracking note under Unreleased and drops a duplicate entry from the 13.1.3 section. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit ed2395f. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY --> --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: Salim TOUBAL <salimtb@users.noreply.github.com>
|
Can we have a PRdescription please? |
|
Also it would be nice to link the core PR with that change ongoing |
|
@tommasini done |



Description
This PR removes cache usage when requesting the Account API to fetch balances, ensuring that forceUpdate calls result in a real network request rather than a near-immediate cache hit.
Currently, AccountsApiDataSource uses { staleTime: 100, gcTime: 100 } for all fetches — including forced ones. This means that even when forceUpdate: true is set (e.g. via AssetsController.getAssets), React Query may return stale cached data within the 100ms window instead of hitting the network. This is incorrect behavior for an explicit force-refresh path.
The fix patches @metamask/assets-controller@13.1.3 so that when request.forceUpdate is set, fetchOptions uses { staleTime: 0, gcTime: 0 } — bypassing the cache entirely and guaranteeing a fresh network fetch. Both .cjs and .mjs builds are patched, and package.json (resolutions + dependencies) and yarn.lock are updated accordingly.
Core PR: MetaMask/core#9870
Changelog
CHANGELOG entry: remove account api cache
Related issues
Fixes:
Manual testing steps
Screenshots/Recordings
Before
ScreenRecording_08-12-2026.15-09-45_1.MP4
After
Pre-merge author checklist
Performance checks (if applicable)
trace()for usage andaddTokenfor an exampleFor performance guidelines and tooling, see the Performance Guide.
Pre-merge reviewer checklist
Note
Low Risk
Small behavioral change in dependency caching for explicit force-refresh only; slightly more API traffic on those paths but no auth or data-model changes.
Overview
Patches
@metamask/assets-controller@13.1.3so forced account/asset fetches actually skip the React Query cache instead of reusing data for ~100ms.In
AccountsApiDataSource, whenrequest.forceUpdateis set,fetchOptionschanges from{ staleTime: 100, gcTime: 100 }to{ staleTime: 0, gcTime: 0 }(both.cjsand.mjsbuilds). That aligns “force update” paths—such asAssetsController.getAssetswithforceUpdate: true—with a real network refresh rather than a near-immediate cache hit.Wiring is updated in
package.json(resolutions+dependencies) andyarn.lockso the app resolves the patched package instead of the stock npm release.Reviewed by Cursor Bugbot for commit a26f683. Bugbot is set up for automated code reviews on this repo. Configure here.