Skip to content

feat: bypass Accounts API server cache after transaction confirmation - #10068

Open
salimtb wants to merge 4 commits into
mainfrom
feat/assets-controller-bypass-cache-on-tx-confirmed
Open

feat: bypass Accounts API server cache after transaction confirmation#10068
salimtb wants to merge 4 commits into
mainfrom
feat/assets-controller-bypass-cache-on-tx-confirmed

Conversation

@salimtb

@salimtb salimtb commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

The Accounts API keeps a 60s server-side cache keyed on the full URL, and WebSocket events do not invalidate it, so a refresh right after a transaction confirms can be answered with the pre-transaction snapshot. forceUpdate only skips the client-side query cache.

getAssets now accepts a bypassCache option; when set, AccountsApiDataSource asks the core-backend client to append a random cacheBuster query param (the mechanism sanctioned by the API team so these requests stay traceable in logs) and skip the client-side cache. The transaction-confirmed refresh passes it; the unapproved-transaction refresh intentionally does not, to keep cache misses rare.

Explanation

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

Low Risk
Scoped opt-in cache busting on balance fetches, mainly after transaction events; no auth or persistence changes, with unit test coverage for URL param behavior.

Overview
Fixes stale balances right after a transaction when forceUpdate only skipped the client TanStack cache but the Accounts API still served a 60s server-side snapshot (WebSocket updates do not invalidate that cache).

core-backend adds optional bypassServerCache on FetchOptions. For v5/v6 multi-account balance calls, it forces staleTime: 0 and appends a fresh random bypassServerCache query param so the API cache keys miss.

assets-controller threads the flag through DataRequestgetAssetsAccountsApiDataSource, and transaction-driven refreshes (#refreshAssetsForTransaction, used for both confirmed and unapproved transaction events) call getAssets with forceUpdate and bypassServerCache: true. Tests cover the data source and API client wiring.

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

salimtb and others added 2 commits September 2, 2026 02:10
…action confirmation

The Accounts API keeps a 60s server-side cache keyed on the full URL, and
WebSocket events do not invalidate it, so a refresh right after a transaction
confirms can be answered with the pre-transaction snapshot. forceUpdate only
skips the client-side query cache.

getAssets now accepts a bypassCache option; when set, AccountsApiDataSource
asks the core-backend client to append a random cacheBuster query param
(the mechanism sanctioned by the API team so these requests stay traceable
in logs) and skip the client-side cache. The transaction-confirmed refresh
passes it; the unapproved-transaction refresh intentionally does not, to
keep cache misses rare.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@salimtb salimtb changed the title feat(assets-controller): bypass Accounts API server cache after transaction confirmation feat: bypass Accounts API server cache after transaction confirmation Sep 2, 2026
@salimtb
salimtb marked this pull request as ready for review September 2, 2026 08:34
@salimtb
salimtb requested review from a team as code owners September 2, 2026 08:34
@salimtb
salimtb deployed to default-branch September 2, 2026 08:34 — with GitHub Actions Active
@salimtb

salimtb commented Sep 2, 2026

Copy link
Copy Markdown
Contributor Author

@cursor fix conflicts

@cursor

cursor Bot commented Sep 2, 2026

Copy link
Copy Markdown

Perfect! I've successfully resolved the merge conflicts on your PR. Here's what I did:

Summary

I resolved the merge conflict in packages/assets-controller/CHANGELOG.md that occurred when merging main into the feat/assets-controller-bypass-cache-on-tx-confirmed branch.

What was conflicting

Both branches had added entries to the Fixed section under Unreleased in the changelog:

  • Your branch: Added a fix for stale balances shown after transaction confirmation (the bypass cache feature)
  • Main branch: Added a fix for stale balances when the Accounts API returns no entry for an asset

Resolution

I kept both changelog entries since they fix different issues:

  1. Your bypass cache fix (PR feat: bypass Accounts API server cache after transaction confirmation #10068) - ensures post-transaction refreshes bypass the server-side cache
  2. The stale balance fix from main (PR fix: read balances from RPC when Accounts API returns none #10061) - handles missing asset entries from the Accounts API

The merge has been committed and pushed successfully. Your PR is now up to date with main and ready for review.

Open in Web Open in Cursor 

…irmed

Co-authored-by: Salim TOUBAL <salimtb@users.noreply.github.com>

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit a26b9fb. Configure here.

Comment thread packages/core-backend/src/api/accounts/client.ts
@cursor
cursor Bot requested review from Kriys94 and bergarces September 2, 2026 12:01
@salimtb
salimtb enabled auto-merge September 2, 2026 12:31
Comment thread packages/core-backend/src/api/shared-types.ts Outdated
Comment thread packages/core-backend/src/api/accounts/client.ts Outdated
Comment thread packages/core-backend/src/api/accounts/client.ts Outdated
Comment thread packages/assets-controller/src/AssetsController.ts Outdated
Comment thread packages/assets-controller/src/AssetsController.ts Outdated
Comment thread packages/assets-controller/src/types.ts Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants