fix: Fix redux store event handler leak in WCv2#27932
Conversation
🔍 Smart E2E Test Selection
click to see 🤖 AI reasoning detailsE2E Test Selection:
These are targeted bug fixes in the WalletConnect V2 session management layer. The changes affect:
Selected tags:
Tag dependencies satisfied: SmokeMultiChainAPI → SmokeNetworkAbstractions + SmokeNetworkExpansion; SmokeNetworkExpansion → SmokeConfirmations. Performance Test Selection: |
|
✅ E2E Fixture Validation — Schema is up to date |
|



Description
Fixes an issue where after a WCv2 connection could still send chainChanged events to the WC relay when the connection was removed. This was happening regardless of if the connection was removed on the wallet side or signaled removed from the WC side.
This PR fixes that by properly unsubscribing from the store.
Changelog
CHANGELOG entry: null
Not user facing.
Related issues
Fixes: https://consensyssoftware.atlassian.net/browse/WAPI-1355
Manual testing steps
Visit https://react-app.walletconnect.com/ in the native browser and smoke test
Screenshots/Recordings
Before
After
Pre-merge author checklist
Pre-merge reviewer checklist
Note
Medium Risk
Touches WalletConnect v2 session lifecycle/cleanup, so mistakes could leave sessions partially disconnected or change disconnect timing. Logic is straightforward and covered by updated unit tests, limiting risk.
Overview
Fixes a WalletConnect v2 listener leak by storing the Redux
store.subscribeunsubscribe inWalletConnect2Sessionand invoking it duringremoveListeners().Updates
WC2Manager.removeAll()to tear down everyWalletConnect2SessionviaremoveListeners()before clearing the sessions map, preventing orphaned subscriptions/bridges whensession_deletefires after local state is cleared. Tests were extended to assert the unsubscribe is called andremoveAll()invokesremoveListeners()for each session.Written by Cursor Bugbot for commit 7633be5. This will update automatically on new commits. Configure here.