-
Notifications
You must be signed in to change notification settings - Fork 5k
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
[Bug]: Network changed events fired with a delay #13375
Comments
I believe I'm seeing a related issue. Metamask (injected provider) disconnects whenever the chain is changed to the Binance Test Network. I can freely switch from it to any network, or between any other networks I've tried, but as soon as I switch back into the binance testnet instead of getting a chainChanged event, I get a disconnect event.
If I reload the page, I am connected just fine. It only breaks when I switch into the testnet from metamask. |
I can confirm that this is an issue with some Binance Smartchain Testnet RPCs. When switching from any chain to Binance Smartchain Testnet, for some RPCs a disconnect event is fired. (and results in a delay) This RPC results in the above error
This one seems to work without issues:
Both are from the binance docs |
Can confirm this happens for other chains and is affecting To reproduce:
Using MM 10.9.3. cc @kevinghim |
same issue observed, any solution? |
@kevinghim here's a very simple reproduction (using MetaMask
window.ethereum.on('disconnect', () => alert('disconnect'));
await window.ethereum.request({ method: 'eth_requestAccounts' });
await window.ethereum.request({
method: 'wallet_switchEthereumChain',
params: [{ chainId: '0xa' }],
}) Or add and switch: await window.ethereum.request({
method: 'wallet_addEthereumChain',
params: [
{
chainId: '0xa',
chainName: 'Optimism',
nativeCurrency: {name: 'Ether', symbol: 'ETH', decimals: 18},
rpcUrls: ['https://mainnet.optimism.io'],
blockExplorerUrls: ['https://optimistic.etherscan.io'],
},
],
});
|
is this still an issue or has been fixed? |
I have the same problem. Switching to custom network sometimes fires |
I've been having this issue for a while, that Metamask will disconnect when I switch to Mumbai. I was certain this was a Metamask issue but found out today that I was missing an |
Same problem here, we are experiencing this issue when switching from Goerli to another network... Is this planned to be fixed? |
@elias-garcia What other network? Ropsten just very recently got deprecated, could that be the issue? |
Hi @einaralex! We are experiencing it when switching from This happened live in Jordi's presentation at Devcon, you can take a look to the exact moment here: https://www.youtube.com/watch?v=3A-LotQjc2k&t=5873s You can see how after switching the network, the Details of the
|
+1, we are experiencing the same issue when switching between Ethereum Mainnet and Optimism Mainnet. |
Experiencing the same issue switching from Polygon to Celo and vice versa |
It seems like this bug is hit every time you switch to a custom network. When I switch between the default Ethereum network loaded in MM and testnets, no disconnect happens. I added a custom Ethereum node with Alchemy as the RPC and now the Dapp disconnects when I switch to it, as well as any other custom network I've added (Optimism, ZKSync etc). |
Has anyone found a solution/workaround for this issue? |
Bump. |
Be fantastic to get this fixed. Still occurring today. |
Any Update? |
is this issue fixed? still occuring for me! |
This is still broken for me but I was able to implement a workaround. I'm using web3modal but I assume you can just put this in whatever function handles your disconnect event.
Stole this from Uniswap/web3-react#709 thank you @niZmosis |
+1, still have the issue |
Confirmed that this is still an issue. disconnect events are erroneously being emitted when chain switch happens. In our case, because we respect this event, we disconnect an authenticated account. |
+1, still reproducible |
+1, issue still exits |
Please note that |
+1 have same issue |
Describe the bug
I hope I'm at the right place because it doesn't seem much of a bug, but maybe something can be done about it.
I'm connecting Metamask to my app, and right after user grants access I check the
chainId
, if it's not the one I expect I dowallet_switchEthereumChain
, and if right after that I do login process again where this time it passeschainId
check and subscriptions happen, and after going this far MM emits eventsdisconnect
or/andaccountsChanged
. Alternatively, without auto-login after chain switch if you click fast enough on login button again after network switch you'll catch this events.BUT it doesn't happen if the target chain is mainnet, in my case it's Binance Smart Chain and it's Testnet that I'm testing.
Again, events related to network switch fire much later after it actually happened
Steps to reproduce
wallet_switchEthereumChain
request asking you to change network to the right onechainId
check passed but still get an event related to changing networks much laterError messages or log output
No response
Version
10.8.1
Build type
No response
Browser
Chrome, Firefox
Operating system
Linux
Hardware wallet
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: