Skip to content

fix(assets-controller): clean up unused assetsInfo/assetsPrice entries on startup - #9806

Open
Prithpal-Sooriya wants to merge 14 commits into
mainfrom
cursor/assets-cleanup-unused-metadata-bedb
Open

fix(assets-controller): clean up unused assetsInfo/assetsPrice entries on startup#9806
Prithpal-Sooriya wants to merge 14 commits into
mainfrom
cursor/assets-cleanup-unused-metadata-bedb

Conversation

@Prithpal-Sooriya

@Prithpal-Sooriya Prithpal-Sooriya commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Explanation

AssetsController's assetsInfo and assetsPrice state slices have never had a delete path: metadata and prices are written whenever assets are fetched or detected, but entries are never removed when the assets stop being referenced. Since both slices are persisted, they grow unbounded over time.

This PR adds a cleanup utility that gets invoked once (through #runStartupRefresh)

References

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

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
Open in Web Open in Cursor 

cursoragent and others added 2 commits August 7, 2026 17:54
…e entries on startup

Co-authored-by: Prithpal Sooriya <prithpal.sooriya@gmail.com>
Co-authored-by: Prithpal Sooriya <prithpal.sooriya@gmail.com>
Comment thread packages/assets-controller/src/AssetsController.ts Outdated
Comment thread packages/assets-controller/src/AssetsController.ts Outdated
cursoragent and others added 3 commits August 7, 2026 18:12
…rt cycle

Co-authored-by: Prithpal Sooriya <prithpal.sooriya@gmail.com>
Co-authored-by: Prithpal Sooriya <prithpal.sooriya@gmail.com>
Co-authored-by: Prithpal Sooriya <prithpal.sooriya@gmail.com>
Comment thread packages/assets-controller/src/AssetsController.ts Outdated
Comment thread packages/assets-controller/CHANGELOG.md Outdated
Comment thread packages/assets-controller/src/utils/cleanupUnusedMetadata.test.ts Outdated
Comment thread packages/assets-controller/src/utils/cleanupUnusedMetadata.ts
Comment thread packages/assets-controller/src/utils/cleanupUnusedMetadata.ts Outdated
Comment thread packages/assets-controller/src/utils/native-assets.test.ts Outdated
Comment thread packages/assets-controller/src/utils/native-assets.ts Outdated
cursoragent and others added 6 commits August 7, 2026 19:49
…/flatMap

Co-authored-by: Prithpal Sooriya <prithpal.sooriya@gmail.com>
Co-authored-by: Prithpal Sooriya <prithpal.sooriya@gmail.com>
Co-authored-by: Prithpal Sooriya <prithpal.sooriya@gmail.com>
Co-authored-by: Prithpal Sooriya <prithpal.sooriya@gmail.com>
Co-authored-by: Prithpal Sooriya <prithpal.sooriya@gmail.com>
Co-authored-by: Prithpal Sooriya <prithpal.sooriya@gmail.com>
@Prithpal-Sooriya
Prithpal-Sooriya marked this pull request as ready for review August 10, 2026 09:56
@Prithpal-Sooriya
Prithpal-Sooriya requested review from a team as code owners August 10, 2026 09:56
Comment thread packages/assets-controller/src/utils/cleanupUnusedMetadata.ts Outdated
Comment thread packages/assets-controller/src/utils/cleanupUnusedMetadata.ts Outdated
Co-authored-by: Prithpal Sooriya <prithpal.sooriya@gmail.com>
Comment thread packages/assets-controller/src/utils/cleanupUnusedMetadata.ts Outdated
cursoragent and others added 2 commits August 10, 2026 09:59
Co-authored-by: Prithpal Sooriya <prithpal.sooriya@gmail.com>
Co-authored-by: Prithpal Sooriya <prithpal.sooriya@gmail.com>
const isUnused = (assetId: string): boolean =>
!keptAssetIds.has(assetId.toLowerCase()) && !isNativeAssetId(assetId);

for (const slice of [state.assetsInfo, state.assetsPrice]) {

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.

nit

Suggested change
for (const slice of [state.assetsInfo, state.assetsPrice]) {
for (const assetId of Object.keys(slice)) {
if (isUnused(assetId)) {
delete slice[assetId];
}
}

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