rainbowkit icon indicating copy to clipboard operation
rainbowkit copied to clipboard

[bug] WalletConnect connector creates multiple instances and gets unsynced from the app

Open iceanddust opened this issue 1 year ago • 5 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

RainbowKit Version

2.2.0

wagmi Version

2.12.25

Current Behavior

After connecting to the WalletConnect connector and reloading the app, a second instance of the connected connector is created, which prevents the wallet from notifying the app about changes, and eventually throwing a Error: No matching key. history: <number> error.

I double checked and this is not an issue if I directly connect through Wagmi's WalletConnect connector. I also tried connecting through WC with a Safe Wallet and a Metamask wallet and could reproduce the problem in both cases.

Expected Behavior

The WalletConnect connection should keep working between reloads of the app, or worst case scenario, it should automatically disconnect on reloads to prevent the bad UX for the user using the app

Steps To Reproduce

  • Open the Minimal Reproducible Example provided
  • Update the projectId for a valid WC project ID
  • Open the preview in a new tab (top-right corner). It's important to open the app in a full tab to reproduce the issue
  • Click the connect button and connect through WalletConnect. In the console you can see that it's connected to a single WC instance
  • Reload the tab
  • Open the console and you will now see that the app is connected to 2 instances of WalletConnect
  • Switch the network through the ConnectButton, confirm in your wallet and you will notice that the app will not be notified about the successful action, then you will be able to see the No matching key. history error in the console

This error seems to affect all messages sent from the wallet to the app, I've also experienced it with transaction statuses on a larger app, where the wallet never notifies the app about confirmed, successful or transactions with errors

Link to Minimal Reproducible Example (CodeSandbox, StackBlitz, etc.)

https://stackblitz.com/edit/new-wagmi-bfc6lr?file=src%2Fwagmi.ts%3AL7

Anything else?

No response

iceanddust avatar Oct 24 '24 21:10 iceanddust

@DanielSinclair can you have a look at this issue? It's preventing Rainbow users from connecting with Safe and WalletConnect

generatorpoint avatar Oct 30 '24 15:10 generatorpoint

I believe I am experiencing the same issue. My dapp is uses Wagmi and RainbowKit to create a WalletConnect connector along with other popular wallets. After refreshing the page, the dapp can still send txs to the mobile wallet to WalletConnect, but after signing them the message fails to be received by my dapp, and the console includes the same No matching key. history errors.

@iceanddust have you found any workaround to this?

nlparis avatar Jan 10 '25 19:01 nlparis

This issue should be fixed by this PR but no one is reviewing it for now.

agualis avatar Mar 06 '25 16:03 agualis

Any updates on this? It's a really annoying issue.

TRCSamurai avatar Jun 11 '25 16:06 TRCSamurai

Hey,

Any chance #2331 could be reviewed and merged? A few of us are running into this issue, and it’s a bit annoying since some dapps using RainbowKit can’t be used with WalletConnect because of it.

Thanks 🙂

0xGeegZ avatar Aug 06 '25 11:08 0xGeegZ