web3-react
web3-react copied to clipboard
Lost connect after switch metamask network a few times
I have use v8 beta for a while, but there is a bug here. Just try these steps:
- connect network on demo page(https://web3-react-mu.vercel.app/)
- switch network from one to another (eg: Polygon Mainnet to Arbitrum One)
- just try step 2 for a few times, the connection is broken
PS: It's ok on v6.
+1 also seeing this issue. Very easily reproducible by switching between polygon and optimism
I'm still tracking it down, I'll jot down my findings so far.
Only chains that it messes up on. Optimism (10) BSC Testnet (97) Fuji (43113) Mumbai (80001)
All testnets mostly, but Optimism Goerli is fine, and the mainnet messes up.
What I've noticed is when switching to these chains, they do no get flagged as isActivating like the others. Also when switching the chain, the only event that the provider is supposed to call is "chainChanged", but you will see with the ones that mess up, the provider fires events for "disconnect", then "connect", then finally "chainChanged".
This is a MetaMask only bug, Coinbase Wallet is fine. I know MetaMask can miss requests if they are fired off to fast, wonder if it's something like that.
This is a bug in MM and has nothing to do with Web3React. We may be able to do something to reconnect when it happens in this library, but really MM needs to fix their extension. MetaMask github
Have a fix for this in this PR. Ended up catching MM's error on disconnect, and if it is error 1013, I don't reset state for the connector.