fix(connect-multichain): clean up MWP session on connection rejection#180
Merged
fix(connect-multichain): clean up MWP session on connection rejection#180
Conversation
When a user rejects a QR code connection in the wallet, the MWP handshake has already completed and stored a session in the KVStore. Without calling dappClient.disconnect(), the stale session persists and causes subsequent connection attempts to enter the resume path with a rejected session, resulting in a timeout.
cefe0f5 to
b094194
Compare
jiexi
approved these changes
Feb 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Problem
When connecting via QR code, the MWP handshake completes and stores a
session:{id}entry in the KVStore before the wallet responds towallet_createSession. If the user then rejects the connection in the wallet:rejectConnection()is called ininitialConnectionMessageHandler, butdappClient.disconnect()is never calleddappClient.disconnect()is the only method that callssessionstore.delete(session.id)to remove the session from the KVStoregetActiveSession()finds this stale session and enters theresumebranch — trying to resume a session the wallet already rejectedFix
Call
dappClient.disconnect()inMWPTransport.connect()'s catch handler so that any connection failure (rejection, timeout, etc.) properly cleans up the dappClient session from the KVStore. The.catch(() => {})on disconnect ensures cleanup errors don't mask the original connection error.Test plan