fix: prevent WalletConnect session proposal race conditions (WAPI-1070)#26121
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. |
e71ce4b to
183bbe0
Compare
🔍 Smart E2E Test Selection
click to see 🤖 AI reasoning detailsE2E Test Selection:
Selected tags rationale:
Not selected:
Performance Test Selection: |
|



Description
Fixes a set of race conditions in the WalletConnect v2 connection flow that caused a "stuck" or looping connection tray when scanning QR codes. The root cause was multiple layers of concurrent/duplicate processing:
The OS can deliver the same deeplink 3-5 times via Linking + Branch. Each delivery called
pair()and pushed a loading modal, stacking duplicate modals on screen.The WalletConnect relay can fire the same
session_proposalevent multiple times when duplicatepair()calls were made, causing duplicate AccountConnect screens.Rapid QR scans caused overlapping proposals to fight over shared state (
wc2Metadata, navigation, approval queue).Changes to the
pendingApprovalsRedux state re-triggeredPermissionApproval'suseEffect, causing repeated navigation to AccountConnect for the same approval.Each issue is fixed at the layer where it occurs:
connect()seenTopics+ 5 s TTLonSessionProposal()proposalLock_handleSessionProposal()handledProposalIdsPermissionApprovallastNavigatedApprovalIdRefAdditionally fixes the
SDKLoadingLottie animation not being visible.Compatibility with #24040: The
PermissionApprovalchange keepspendingApprovalsin theuseEffectdeps (so the effect still re-runs when the queue changes, preventing stuck approvals). The added ref guard only skips navigation for the same approval ID; new approvals with a different ID navigate normally.Changelog
CHANGELOG entry: Fixed WalletConnect connection tray getting stuck or looping when scanning QR codes, and fixed the loading animation not displaying during connection.
Related issues
Fixes: WAPI-1070
Manual testing steps
Screenshots/Recordings
Screen.Recording.2026-02-16.at.14.16.502.mov
Pre-merge author checklist
Note
Medium Risk
Touches WalletConnect v2 connection/proposal control flow and approval navigation, so regressions could block or duplicate connection attempts. Changes are localized and include added guards and updated tests, reducing but not eliminating behavioral risk.
Overview
Prevents WalletConnect v2 connection flows from looping/stacking by deduplicating
connect()calls per pairing topic (5s TTL) and serializingsession_proposalhandling with a lock plus proposal-id dedupe.Fixes repeated AccountConnect navigation by guarding
PermissionApprovalagainst re-navigating for the same approvalmetadata.ideven whenpendingApprovalschanges, and updates tests accordingly. Also fixes the SDK loading tray animation sizing by adding an explicit LottieaspectRatio, and tightens logging/metadata cleanup on proposal rejection to avoid stale UI state.Written by Cursor Bugbot for commit 183bbe0. This will update automatically on new commits. Configure here.