metamask-extension icon indicating copy to clipboard operation
metamask-extension copied to clipboard

[Bug]: fetchWithCache Causing Storage Increases in Token Details

Open darkwing opened this issue 6 months ago • 1 comments

Describe the bug

The asset details page is using fetchWithCache to retrieve asset details from the following URL:

https://price.api.cx.metamask.io/v1/chains/${chainId}/historical-prices/${address}?vsCurrency=${currency}&timePeriod=${timePeriod}

This caches historical information by chain ID, contract address, and time range. The response is added to localStorage but never cleared, thus bloating the user's storage.

We should:

  1. Use native fetch with request caching to make these requests
  2. Write a migration that clears out any localStorage keys that start with https://price.api.cx.metamask.io/v1/chains/

Expected behavior

Nothing added to localStorage

Screenshots/Recordings

No response

Steps to reproduce

  1. Go to any asset details page
  2. See storage grow

Error messages or log output


Detection stage

In production (default)

Version

12.18.2

Build type

None

Browser

Chrome

Operating system

MacOS

Hardware wallet

No response

Additional context

No response

Severity

No response

darkwing avatar Jun 17 '25 20:06 darkwing

I am checking this one during the Quality Sprint. It doesn't look like this was addressed in the Epic ticket linked, so I am leaving it open for the team to look over.

epop-cs avatar Dec 09 '25 19:12 epop-cs