Skip to content

fix: avoid making unnecessary api calls#7811

Merged
juanmigdr merged 9 commits intomainfrom
fix/repeated-api-calls-to-supported-networks
Feb 9, 2026
Merged

fix: avoid making unnecessary api calls#7811
juanmigdr merged 9 commits intomainfrom
fix/repeated-api-calls-to-supported-networks

Conversation

@juanmigdr
Copy link
Member

@juanmigdr juanmigdr commented Feb 2, 2026

Explanation

Updated the code so that we do not make subsequent API calls to the same endpoint with the same params and so that we cache the response to avoid unnecessary re-fetching

References

https://consensyssoftware.atlassian.net/browse/ASSETS-2582

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
Low risk: changes are limited to caching/deduping logic around Price API metadata fetches and adds a targeted unit test; main risk is stale supported-network/currency lists if cache invalidation expectations change.

Overview
Improves Price API performance by deduplicating concurrent calls to /v2/supportedNetworks via an in-flight promise cache in fetchSupportedNetworks(), and clearing that promise on completion.

Reduces background traffic by only triggering the non-blocking refresh in fetchTokenPrices() and fetchExchangeRates() when the supported networks/currencies caches are empty, and updates tests to assert concurrent-call deduplication.

Written by Cursor Bugbot for commit 0ebef38. This will update automatically on new commits. Configure here.

@juanmigdr juanmigdr requested a review from a team as a code owner February 2, 2026 15:23
Copy link

@cursor cursor bot left a comment

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.

@juanmigdr
Copy link
Member Author

@cursor update the assets Changelog to cater for the changes in my PR

@cursor
Copy link

cursor bot commented Feb 3, 2026

I've successfully updated the assets-controllers changelog to document the changes from your PR. Here's what I added:

Updated: packages/assets-controllers/CHANGELOG.md

Added to [Unreleased] section:

  • Optimize Price API performance by deduplicating concurrent API calls
  • Add in-flight promise caching for fetchSupportedNetworks() to prevent duplicate concurrent requests
  • Update fetchTokenPrices() and fetchExchangeRates() to only refresh supported networks/currencies when no cached value exists
  • Add resetSupportedNetworksCache() method to clear cached promises when needed

The changelog entry properly documents the performance optimizations your PR introduces, including the deduplication of concurrent API calls, improved caching behavior, and the new reset functionality. The changes have been committed and pushed to the fix/repeated-api-calls-to-supported-networks branch.

Open in Cursor Open in Web

Co-authored-by: juan.gutierrez <juan.gutierrez@consensys.net>
@cursor cursor bot requested a review from a team as a code owner February 3, 2026 09:25
salimtb
salimtb previously approved these changes Feb 9, 2026
@juanmigdr juanmigdr enabled auto-merge February 9, 2026 13:00
@juanmigdr juanmigdr added this pull request to the merge queue Feb 9, 2026
Merged via the queue into main with commit 0a87537 Feb 9, 2026
302 checks passed
@juanmigdr juanmigdr deleted the fix/repeated-api-calls-to-supported-networks branch February 9, 2026 13:10
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