MetaMask / metamask-extension

:globe_with_meridians: :electric_plug: The MetaMask browser extension enables browsing Ethereum blockchain enabled websites
https://metamask.io
Other
11.57k stars 4.73k forks source link

[Bug]: wallet_switchEthereumChain no longer working after update to 10.28.2 Chrome #18509

Closed SolidityDevTech closed 1 year ago

SolidityDevTech commented 1 year ago

Describe the bug

After the release of 10.28.2 wallet_switchEthereumChain is no longer working. Error in console is {code: -32603, message: 'networkConfigurationId undefined does not match a configured networkConfiguration', data: {…}}. 10.28.1 has an issue where user has to approve the function twice. Downgrading to 10.26.1 allowed the wallet_switchEthereumChain to function. (Did not try versions between 10.26.1 and 10.28.1) It appears that the issue only happens when switching to a chain other than Ethereum but can not confirm 100%

Steps to reproduce

  1. Ensure that extension version 10.28.2 is installed in Chrome Desktop.
  2. Visit a site which utilizes wallet_switchEthereumChain, trade.coinbook.app is an example.
  3. Utilize Network dropdown on DAPP to select a chain to switch to. Metamask will open with correct chain swicth prompt. Error is logged after clicking Approve.
  4. Depending on DAPP configuration there may be a catch that calls wallet_addEthereumChain on error.

Error messages or log output

{code: -32603, message: 'networkConfigurationId undefined does not match a configured networkConfiguration', data: {…}}

Version

10.28.2

Build type

None

Browser

Chrome

Operating system

MacOS

Hardware wallet

No response

Additional context

No response

nautsimon commented 1 year ago

bump, this was an issue before version 10.28.2 that #18483 aimed to fix but did not successfully do so

18453

0xnakato commented 1 year ago

same here

simonzg commented 1 year ago

same issue identified both on MacOS and Windows

sjunaiduk commented 1 year ago

Metamask v10.28.2 on Chrome has created this bug. Hopefully a fix soon.

qqqzhch commented 1 year ago

Metamask v10.28.2 on Chrome on MacOS Hopefully a fix soon.

scotthconner commented 1 year ago

Also running into this. It's broken existing dapp deployments as well?

MetaMask - RPC Error: networkConfigurationId undefined does not match a configured networkConfiguration

danjm commented 1 year ago

If you are experiencing this, you can switch networks within MetaMask. Of course, we want to fix this properly so that you don't have to do that.

I am trying to understand the problem. Can someone who is experiencing this try the following:

  1. Open MetaMask
  2. Make sure you are on a network other than the one you are trying to switch to
  3. Open the network dropdown and delete the network you are trying to switch to by clicking the "X" next to the network.
  4. Go back to the dapp and refresh the page
  5. Click whatever button prompts you to connect to the network. It should prompt you to add the network.
  6. Confirm the addition of the network but DO NOT confirm switching to the network if you are shown that immediately, and click "Cancel" on the switch network prompt.
  7. In the dapp, click the button that will again cause the switch network prompt. This time, confirm the switching of the network.

If someone can try that and report the results, it can help with the investigation of this bug.

Also, if someone can share any dapps where they are experiencing this bug, it can help with the investigation.

0xnakato commented 1 year ago

If you are experiencing this, you can switch networks within MetaMask. Of course, we want to fix this properly so that you don't have to do that.

I am trying to understand the problem. Can someone who is experiencing this try the following:

  1. Open MetaMask
  2. Make sure you are on a network other than the one you are trying to switch to
  3. Open the network dropdown and delete the network you are trying to switch to by clicking the "X" next to the network.
  4. Go back to the dapp and refresh the page
  5. Click whatever button prompts you to connect to the network. It should prompt you to add the network.
  6. Confirm the addition of the network but DO NOT confirm switching to the network if you are shown that immediately, and click "Cancel" on the switch network prompt.
  7. In the dapp, click the button that will again cause the switch network prompt. This time, confirm the switching of the network.

If someone can try that and report the results, it can help with the investigation of this bug.

Also, if someone can share any dapps where they are experiencing this bug, it can help with the investigation.

@danjm I can't even delete the network in step 3, the network is still there after confirming the deletion. Could it be a new issue?

Btw you can try our dapp experiencing the issue https://syncswap.xyz/

danjm commented 1 year ago

@0xnakato Ah, I see, you are right.

Well I understand the problem now and am working on a fix.

This bug will be experienced by anyone who added a network while on v10.27.0 or earlier, and are now on v10.28.1 or v10.28.2 and trying to confirm a dapp prompted switch to that network. This bug will not affect users who first added the network, via a dapp wallet_addEthereumChain request, while on v10.28.1 . This bug also won't affect users who added the network via the MetaMask UI in v10.28.1

The simplest work around is to open MetaMask and use the network switcher. But you will have to do that every time a dapp prompts you to switch to that network.

If you want to permanently fix the issue for a given network, you can open MetaMask, then open "Settings", then select the "Network" tab of settings and edit any field in any way. Save the change in the network form. Switching to this network from dapp (or deleting it) will succeed. I have demo's this workaround in the attached video, which first shows the failure to switch and then shows the successful network switch after editing the rpc url in the network form by adding a trailing /

https://user-images.githubusercontent.com/7499938/230705576-177c2927-e3d7-4959-a211-d767953467a6.mp4

0xnakato commented 1 year ago

@danjm Awesome! Thank you for the investigation, details and instructions! Really appreciate it and looking forward to the fix!

mykcryptodev commented 1 year ago

thank you @danjm I think your explanation probably saved me hours of fumbling this weekend <3

RodeRickIsWatching commented 1 year ago

@danjm Facing the same problem, and temporarily fixed by removing and readd the network. BTW will u fix it in this version? I think it may be a liitle complex for common users to understand why they need to remove and readd the network, and also how to do it. Thanks!

mhmmdhajizade commented 1 year ago

@danjm Thank you for explanation. This solution fixed the problem but is there any chance that this problem fix in next versions of metamask? It is gonna be big problem for dapps that using metamask for connect wallet.

Jason2d2 commented 1 year ago

This is still causing issues since 10.28.1. Have you tried switching to a custom network, Ganache? I am able to switch via dapp to a common network, like Sepolia, but unable to switch to Localhost http://127.0.0.1:8545, chain id 1337.

Error: networkConfigurationId undefined does not match a configured networkConfiguration

bifot commented 1 year ago

same for me, and also on uniswap too

Bot80926 commented 1 year ago

can't delete network successfully. the only way to switch network is open metaMask and use network switcher :(

@0xnakato Ah, I see, you are right.

Well I understand the problem now and am working on a fix.

This bug will be experienced by anyone who added a network while on v10.27.0 or earlier, and are now on v10.28.1 or v10.28.2 and trying to confirm a dapp prompted switch to that network. This bug will not affect users who first added the network, via a dapp wallet_addEthereumChain request, while on v10.28.1 . This bug also won't affect users who added the network via the MetaMask UI in v10.28.1

The simplest work around is to open MetaMask and use the network switcher. But you will have to do that every time a dapp prompts you to switch to that network.

If you want to permanently fix the issue for a given network, you can open MetaMask, then open "Settings", then select the "Network" tab of settings and edit any field in any way. Save the change in the network form. Switching to this network from dapp (or deleting it) will succeed. I have demo's this workaround in the attached video, which first shows the failure to switch and then shows the successful network switch after editing the rpc url in the network form by adding a trailing /

iseekTo commented 1 year ago

@Bot80926 Yes, you are right, this is really a bad ux :(

hope Metamask can fix it :)

Holybasil commented 1 year ago

waiting for a fix

xl2412 commented 1 year ago

same for me, waiting for a fix

zenland-dao commented 1 year ago

Worked fine with Metamask Version 10.28.2 and Chrome Version 111.0.5563.65. Decided to update Chrome to 112.0.5615.50 - network switch stopped working. Tested on Zenland App

luneShaoGM commented 1 year ago

same for me, Metamask Version 10.28.2 and Chrome Version 111.0.5563.146.

egorbond31 commented 1 year ago

same, waiting for a fix 🙏

kuilaurence commented 1 year ago

First remove the previously added network, then re-add it, and the network switching works again. It is speculated that this is related to a Chrome update.

Sotatek-DungTran2 commented 1 year ago

Hi all with this issues , I solved with change method call wallet _switchEthereumChain to wallet_addEthereumChain. And in config wallet_addEthereumChain you change property rpcUrls : ['rpc_url/'] ( Example for abitrum network
rpcUrls: ["https://arb1.arbitrum.io/rpc/", "https://rpc.ankr.com/arbitrum/"], ) Summary The metamask document recommend use wallet_addEthereumChain for switch network and with method wallet_addEthereumChain you can config all for network ( name , chainID , rpc )

nmikhaylovskiy commented 1 year ago

Hi I have same problem

Wait for fix

livingrockrises commented 1 year ago

waiting for a fix

LevanOzashvili commented 1 year ago

same issue on multiple dapps. waiting for a fix.

NicolasCastroGarcia commented 1 year ago

Same issue here, waiting for a fix!

Rcontre360 commented 1 year ago

Same here, waiting for a fix!

paro-paro commented 1 year ago

many dapps are broken! waiting for a fix!

ablevargheseme commented 1 year ago

waiting for a fix

s0wcy commented 1 year ago

Same issue, works when deleting the manually added network and using auto import. Not UX friendly at all for our customers...

AdamB2023 commented 1 year ago

Same issue here, working on a fix.

daedboi commented 1 year ago

Same issue here, this is delaying a new bridge integration into our dapp due to bad UX.

petermazzocco commented 1 year ago

I believe I'm experiencing the same issue as well, but I am fairly new to dApp development (1 year now).

I am trying to set up my connectWallet function for my dApp and am requiring users to switch to Mumbai (for now), the wallet pops up to switch but then throws the error:

networkConfigurationId undefined does not match a configured networkConfiguration

Hope it's just a small bug and you guys can get it figurd out :)

timothycarambat commented 1 year ago

Founder of Mintplex here. We support 7 blockchains through our launchpad. This bug seems limited to only non-native metamask chains.

wallet_switchEthereumChain does work for any chains pre-loaded into metamask (Etherum, Goerli, Sepolia, Local) but any chains that have been added to wallet prior to ~April 7, 2023 (Polygon, Optimism, BNB, etc etc) will not respond to wallet_switchEthereumChain anymore.

This also is the case for wallet_addEthereumChain actions

timothycarambat commented 1 year ago

Was able to fix this by deleting (open settings->networks) and removing all non-locked networks from my current install of MetaMask and re-adding them by any means (chainlist, dAPP, explorer page), and now the wallet add and switch methods work in dApp.

danjm commented 1 year ago

Thanks everyone for your input on this. We are going to try to have a fix published this week, hopefully within a day or two (but exact timelines can't be guaranteed).

See my previous comment for some notes on workarounds from a users perspective.

For dapp developers trying to avoid their users having to follow a workaround, you may find this approach mentioned above helpful https://github.com/MetaMask/metamask-extension/issues/18509#issuecomment-1501607666

Jason2d2 commented 1 year ago

Founder of Mintplex here. We support 7 blockchains through our launchpad. This bug seems limited to only non-native metamask chains.

wallet_switchEthereumChain does work for any chains pre-loaded into metamask (Etherum, Goerli, Sepolia, Local) but any chains that have been added to wallet prior to ~April 7, 2023 (Polygon, Optimism, BNB, etc etc) will not respond to wallet_switchEthereumChain anymore.

This also is the case for wallet_addEthereumChain actions

Local 1337 does not work for me. I can use metamask to switch, but cannot call wallet_switchethereumchain.

thelastinuit commented 1 year ago

I have the same issue but only on Brave. Firefox and Chromes work just fine.

HappySean2845 commented 1 year ago

Same issue here

LimFull commented 1 year ago

Same here

Davidonelove commented 1 year ago

My own is showing me cloud error

NBMSacha commented 1 year ago

Same here.

ugurcanomur commented 1 year ago

same

radchenk0 commented 1 year ago

Same here, waiting for a fix. Thanks and appriciate your work, team. Removing/readding chains did help, but only via expanded view!

nguyenphanhuynh commented 1 year ago

I use MetaMask extension with Brave browser - Version 1.50.114 Chromium: 112.0.5615.49 (Official Build) (arm64), and still face with the issue

SolidityDevTech commented 1 year ago

Thank you @danjm!

nautsimon commented 1 year ago

@danjm! beast!

happy-cutman commented 1 year ago

Chrome version 112.0.5615.50 issue is still here