fix(assets-controller): hardened error handling#8294
Conversation
f57996a to
4b711c2
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
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); |
There was a problem hiding this comment.
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.


Explanation
References
Checklist
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
onActiveChainsUpdatedhandling inAssetsController, and guardsRpcDataSourcebalance/detection polling callbacks plusStakedBalanceDataSourcepolling callback so failures are logged instead of rejecting poll ticks.Updates token/price enrichment to respect v3 API asset ID limits:
TokenDataSourceandPriceDataSourcenow split requests into chunks of max 120 IDs and execute chunk fetches in parallel with bounded concurrency viap-limit(including dual-currency price fetches). Adds coverage to verify chunking behavior, and hardensSnapDataSourceagainst missing/undefined balances payload fields.Written by Cursor Bugbot for commit 01c36b2. This will update automatically on new commits. Configure here.