Description
Describe the bug
When trying to add a network from any dapp MM throws an unexpected error even though it added network.
Here is a codesandbox of the issue on add network: https://codesandbox.io/p/sandbox/connect-metamask-plkgo
this example adds gnosis network and MM throws an error -32603, message
:
"f is not a function"
stack
:
"TypeError: f is not a function\n at chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/background-0.js:1:105287\n "
Expected behavior
When adding a network from a dapp like:
"method": "wallet_addEthereumChain",
"params": [
{
chainId: "0x64",
chainName: "Gnosis",
rpcUrls: [
"https://rpc.gnosischain.com"
],
iconUrls: [
"https://xdaichain.com/fake/example/url/xdai.svg",
"https://xdaichain.com/fake/example/url/xdai.png"
],
nativeCurrency: {
name: "XDAI",
symbol: "XDAI",
decimals: 18
},
blockExplorerUrls: [
"https://blockscout.com/poa/xdai/"
]
}
],
});
like as provided by the documentation on https://docs.metamask.io/wallet/reference/json-rpc-methods/wallet_addethereumchain/ with valid configuration it shouldnt throw any error.
Screenshots/Recordings

Steps to reproduce
- go to codesanbox: https://codesandbox.io/p/sandbox/connect-metamask-plkgo
- click on add network
- check the alert that outputs the exception returned by MM
Error messages or log output
useErrorHandler.tsx:107 Extension error: code: -32603
{code: -32603, message: 'f is not a function', data: {…}}
code
:
-32603
data
:
cause
:
message
:
"f is not a function"
stack
:
"TypeError: f is not a function\n at chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/background-0.js:1:105287\n at async chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/background-0.js:1:98525"
[[Prototype]]
:
Object
[[Prototype]]
:
Object
message
:
"f is not a function"
[[Prototype]]
:
Object
Detection stage
In production (default)
Version
12.16.0
Build type
None
Browser
Chrome
Operating system
MacOS
Hardware wallet
No response
Additional context
No response
Severity
- Medium
We require the handling of error in case the user rejects or we wrongly add a wrong configuration to add network
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Status