Repository navigation
fix(core): unsubscribe connect after a wallet-initiated connection - #5265
Merged
tmm merged 2 commits intoNov 12, 2026
Merged
Conversation
The connect handler removed `change` from the `connect` event, so the listener stayed attached. Injected wallets then treated the next account change as a new connection and could replace the active connector.
|
@mortezashojaei is attempting to deploy a commit to the Wevm Team on Vercel. A member of the Team first needs to authorize it. |
🦋 Changeset detectedLatest commit: a76c4d9 The changes in this PR will be included in the next version bump. This PR includes changesets to release 5 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Contributor
Author
|
@tmm Any comments on this one? should we quick one to review 👀 |
Contributor
Author
|
@tmm Bump here 👀 |
Amp-Thread-ID: https://ampcode.com/threads/T-1f097e0c-ceb6-4b64-9699-40ca15560935 Co-authored-by: tmm <tmm@tmm.dev>
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
When a wallet connects on its own (MetaMask “manually connect”, or
accountsChangedbefore the app callsconnect()),createConfigis supposed to stop listening forconnect. The handler callsemitter.off('connect', change), butchangewas never subscribed to that event, so theconnectlistener stays.injectedtreats a leftoverconnectlistener as “still disconnected”. The next account change is emitted as anotherconnect, and that path setsstate.current. A background wallet switching accounts can replace the active connector.connect()andreconnect()already unsubscribe the realconnectlistener. This handler now does the same.Test plan
connectlistener (fails on main: count stays1)state.current(fails on main: current switches to that wallet)createConfig,connect,disconnect, andreconnecttests