chore: don't fire social leaderboard queries while wallet is locked#29567
Conversation
|
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. |
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.
Reviewed by Cursor Bugbot for commit 3a5f459. Configure here.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #29567 +/- ##
==========================================
- Coverage 82.15% 81.89% -0.26%
==========================================
Files 5178 5178
Lines 137450 137489 +39
Branches 31079 31090 +11
==========================================
- Hits 112924 112600 -324
- Misses 16875 17237 +362
- Partials 7651 7652 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
🔍 Smart E2E Test Selection
click to see 🤖 AI reasoning detailsE2E Test Selection: The SocialLeaderboard and TopTraders components are part of the Trending/discovery section of the wallet homepage, which falls under SmokeWalletPlatform (Trending discovery tab, browsing content feeds including Tokens, Perps, Sites sections). No E2E tests exist specifically for the Social Leaderboard feature, so SmokeWalletPlatform is the closest applicable tag to validate the surrounding feature area. No other tags are warranted: no confirmations, no account management, no network changes, no browser/snap/swap/stake flows are touched. The changes are isolated to hook-level query guards. Performance Test Selection: |
|




Description
We had a Sentry error (getBearerToken - unable to proceed, wallet is locked) caused by TanStack Query refetching social leaderboard and trader profile/positions queries while the wallet is locked.
The root cause is that
ReactQueryServicewiresAppStateto TanStack'sfocusManager, so every app foreground triggers a refetch of all stale queries. SincestaleTime: 0is hardcoded in @metamask/react-data-query, all queries are always stale. If the wallet auto-locked while the app was backgrounded, the refetch on foreground hitsgetBearerToken → #assertIsUnlocked → throws.To address this we can gate the enabled prop on
selectIsUnlockedin the three affected hooks. TanStack fully pauses a query (no refetch interval, no focus refetch, no reconnect refetch) when enabled: false. On wallet unlock, the Redux selector triggers a re-render and the query immediately resumes.The updated hooks are:
useTopTradersuseTraderProfileuseTraderPositionsCached data continues to be shown while locked, so there is no visual regression.
Changelog
CHANGELOG entry: null
Related issues
Fixes:
Manual testing steps
Screenshots/Recordings
Before
After
Pre-merge author checklist
Performance checks (if applicable)
trace()for usage andaddTokenfor an exampleFor performance guidelines and tooling, see the Performance Guide.
Pre-merge reviewer checklist
Note
Low Risk
Small, localized change to query
enabledconditions; main risk is unintentionally suppressing expected refetches when lock state is misreported.Overview
Prevents social leaderboard-related TanStack queries from firing while the wallet is locked by gating each hook’s
useQueryenabledflag onselectIsUnlocked.This updates
useTopTraders,useTraderProfile,useTraderPositions, anduseTraderPositionto stop focus/interval refetches during lock, and adjusts unit tests to mockselectIsUnlockedand assert queries are disabled when locked.Reviewed by Cursor Bugbot for commit 72fcf20. Bugbot is set up for automated code reviews on this repo. Configure here.