Skip to content

fix(assets-controller): hardened error handling#8294

Open
Kriys94 wants to merge 1 commit intomainfrom
fix/TryCatch
Open

fix(assets-controller): hardened error handling#8294
Kriys94 wants to merge 1 commit intomainfrom
fix/TryCatch

Conversation

@Kriys94
Copy link
Copy Markdown
Contributor

@Kriys94 Kriys94 commented Mar 25, 2026

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

Medium Risk
Changes token metadata and spot-price fetching to chunk and parallelize API calls, which can affect request volume/ordering and backend rate limits. Also wraps several polling/update callbacks to prevent unhandled exceptions, reducing crash risk but potentially masking bugs behind logs.

Overview
Improves assets pipeline robustness by preventing unhandled exceptions in several async update paths: wraps onActiveChainsUpdated handling in AssetsController, and guards RpcDataSource balance/detection polling callbacks plus StakedBalanceDataSource polling callback so failures are logged instead of rejecting poll ticks.

Updates token/price enrichment to respect v3 API asset ID limits: TokenDataSource and PriceDataSource now split requests into chunks of max 120 IDs and execute chunk fetches in parallel with bounded concurrency via p-limit (including dual-currency price fetches). Adds coverage to verify chunking behavior, and hardens SnapDataSource against missing/undefined balances payload fields.

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

@Kriys94 Kriys94 force-pushed the fix/TryCatch branch 3 times, most recently from f57996a to 4b711c2 Compare March 27, 2026 10:42
@Kriys94 Kriys94 marked this pull request as ready for review March 27, 2026 10:42
@Kriys94 Kriys94 requested review from a team as code owners March 27, 2026 10:42
Copy link
Copy Markdown

@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.

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.

),
),
);
usdPrices = Object.assign({}, ...usdChunkResults);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Non-USD price fetches serialized instead of parallel

Medium Severity

For non-USD users, the old code ran selected-currency and USD fetchV3SpotPrices calls in parallel via Promise.all. The new code fully awaits all selected-currency chunk results before starting any USD chunk requests, serializing what was previously parallel. Since the pLimit instance is shared, both sets of chunks could safely be dispatched together through the same limiter. For the common case (≤120 assets, single chunk per currency), this roughly doubles the price-fetch latency on every poll tick for all non-USD users.

Fix in Cursor Fix in Web

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant