-
Notifications
You must be signed in to change notification settings - Fork 758
Description
Is there an existing issue for this?
- I have searched the existing issues
RainbowKit Version
2.2.8
wagmi Version
2.10.2
Current Behavior
Hi there :)
First of all thanks for your work on the rainbowkit
library! It makes managing wallets so much easier!
I work on a project called CartesiScan - a app for inspecting and analyzing Cartesi rollups applications. You can connect a web3 wallet to the app and perform transactions like ERC-20
to the listed applications on the platform. The app is built with NextJS.
Recently we updated rainbowkit
and started observing a strange issue related to the navigation in the app when your wallet is disconnected.
While being with a disconnected wallet and when using SPA navigation (for example NextJS's AppRouter
) getAccounts
(https://github.com/wevm/wagmi/blob/main/packages/connectors/src/walletConnect.ts#L240C11-L240C17) method from the MetaMask SDK is being re-invoked many times. If you push an entry to the history state, the getAccounts
method is re-invoked hundreds of times resulting in slow navigation for the app.
Please note that this issue is occurring also when hard-refreshing a page so it's not limited only to SPA navigation. Still, in this case the slowdown is not that severe.
Expected Behavior
While being with a disconnected wallet, getAccounts
from the MetaMask SDK probably should not be re-invoked multiple times. SPA navigation should not be affected. Same applies for hard navigation between pages.
Steps To Reproduce
- Go to https://rollups-explorer-sepolia-c4x8xnppc-cartesi.vercel.app/inputs?query=&pg=1<=10&version=
- Connect and then disconnect your wallet
- Attempt to use the pagination on the page
- Observe that it takes significant amount of time for the next page to load
Link to Minimal Reproducible Example (CodeSandbox, StackBlitz, etc.)
https://rollups-explorer-sepolia-c4x8xnppc-cartesi.vercel.app/inputs?query=&pg=1<=10&version=
Anything else?
I managed to track the cause of this issue by measuring the performance of https://rollups-explorer-sepolia-c4x8xnppc-cartesi.vercel.app/inputs?query=&pg=1<=10&version= when using the pagination on that page. I analyzed the function calls and noticed that there's a ~5 second scripting that's happening in this case. Digging into the scripting portion led me to the getAccounts
method from the MetaMask SKD. I'm attaching a video of my debugging so you can get a better understanding of what is happening:
https://drive.google.com/file/d/13DK3-PmVogs1CPuReZVTJduK5nHFitSp/view?usp=drive_link
Also, this issue is not happening on rainbowkit
v2.2.7
, so it's probably related to the recent utilization of the MetaMask SDK listed here.