Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lost connect after switch metamask network a few times #709

Open
jxiaox opened this issue Nov 30, 2022 · 3 comments
Open

Lost connect after switch metamask network a few times #709

jxiaox opened this issue Nov 30, 2022 · 3 comments

Comments

@jxiaox
Copy link

jxiaox commented Nov 30, 2022

I have use v8 beta for a while, but there is a bug here. Just try these steps:

  1. connect network on demo page(https://web3-react-mu.vercel.app/)
  2. switch network from one to another (eg: Polygon Mainnet to Arbitrum One)
  3. just try step 2 for a few times, the connection is broken

PS: It's ok on v6.

@ohitslaurence
Copy link

+1 also seeing this issue. Very easily reproducible by switching between polygon and optimism

@niZmosis
Copy link

niZmosis commented Dec 23, 2022

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

@niZmosis
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants