fix(perps): address bugbot findings from core PR #7941#26474
fix(perps): address bugbot findings from core PR #7941#26474abretonc7s merged 9 commits intomainfrom
Conversation
- Add missing 'canceled' spelling in deposit+order cancellation check - Mark cancelled deposits as 'cancelled' in persisted state - Null activeProviderInstance on disconnect to prevent stale reads - Tear down preload timer and subscriptions in disconnect() - Move analytics/debug side effects out of immer producer
|
CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes. |
|
Only log "Updated withdrawal status" when a matching withdrawal was actually found and mutated.
Aligns with the invariant that status and success are always set together on deposit request updates.
…ateWithdrawalStatus The debugLog call was accidentally placed inside the shouldTrack guard when side effects were moved out of the immer producer, causing it to only log on status changes. Restore original behavior by logging whenever a matching withdrawal is found.
Cover the new preload timer/subscription teardown branches in disconnect() to reach 100% new code coverage.
🔍 Smart E2E Test Selection
click to see 🤖 AI reasoning detailsE2E Test Selection:
These are bug fixes and code quality improvements that affect the Perps deposit/withdrawal flows. The PerpsController is not integrated into the core Engine but is a standalone feature controller. The changes don't affect initialization order, messenger configuration, or state schema. Per the tag descriptions:
Performance Test Selection: |


Description
Addresses 5 confirmed Bugbot findings from Core PR #7941.
What changed
.catch()only checked'cancelled', not'canceled''pending'activeProviderInstanceafter disconnect — standalone reads could route through a disconnected providertrackPerpsEvent()and#debugLog()moved out ofthis.update()Disconnect design note
Fix 4 inlines the preload cleanup logic from
stopMarketDataPreload()rather than calling it directly, becausestopMarketDataPreload()calls#cleanupStandaloneProvider()fire-and-forget, whiledisconnect()needs the awaited version to prevent races with reconnection.Changelog
CHANGELOG entry: null
Related issues
Fixes: Bugbot findings on MetaMask/core#7941
Manual testing steps
Screenshots/Recordings
N/A — internal controller logic, no UI changes.
Pre-merge author checklist
Pre-merge reviewer checklist
Note
Medium Risk
Touches deposit/withdrawal status transitions and disconnect teardown ordering, which can affect transaction UX, metrics emission, and background polling behavior if regressions occur.
Overview
Fixes several PerpsController lifecycle edge cases around deposits, withdrawals, and teardown.
Deposit tracking now correctly treats both
cancelledandcancelederror strings as user cancellation, and ensures non-order deposit cancellations update the correspondingdepositRequestsentry tocancelledinstead of leaving itpending.updateWithdrawalStatusno longer performs analytics/logging side-effects inside thethis.update()immer producer; it computes whether tracking/logging is needed during the state update and runstrackPerpsEvent/#debugLogafterward.disconnect()now proactively stops market-data preload intervals and unsubscribes messenger listeners, resets cached preload config, clearsactiveProviderInstanceto avoid stale routing, and awaits standalone-provider cleanup. A new unit test asserts preload work does not continue after disconnect.Written by Cursor Bugbot for commit 330b560. This will update automatically on new commits. Configure here.