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

Invalid warning: Could not fetch chain ID. Is your RPC URL correct? #13167

Closed
danfinlay opened this issue Dec 27, 2021 · 11 comments
Closed

Invalid warning: Could not fetch chain ID. Is your RPC URL correct? #13167

danfinlay opened this issue Dec 27, 2021 · 11 comments
Labels
area-customNetworks Sev3-low Low severity; minimal to no impact upon users stale issues and PRs marked as stale team-extension-platform type-bug

Comments

@danfinlay
Copy link
Contributor

Reproduction steps:

  1. Settings > Networks > Add Network
  2. Enter in a valid network settings but with a localhost (like https://localhost:8871)
  3. Get the warning Could not fetch chain ID. Is your RPC URL correct?

Looking in the network tab of the background process, I can see that no chain_id validation request was sent. It seems some validation is getting triggered incorrectly, and preventing adding locally-hosted custom networks.

This error can also be shown when trying to edit the RPC of an existing domain to be a local one. So for example alternative repro:

  1. Add a chain on https://chainlist.org/ like Optimistic Ethereum
  2. Go to Settings > Networks > [the chain you just added]
  3. Try editing the RPC to be https://localhost:8871.
  4. You should get the above warning, although no network request is issued.
@danfinlay danfinlay added type-bug area-customNetworks Sev2-normal Normal severity; minor loss of service or inconvenience. labels Dec 27, 2021
@danjm
Copy link
Contributor

danjm commented Jan 6, 2022

@danfinlay Were you running a local node at https://localhost:8871 when you saw this bug?

@EHaracic EHaracic self-assigned this Jan 7, 2022
@david0xd
Copy link
Contributor

david0xd commented Jan 11, 2022

I've been trying a couple of times to test this and to me it seems to be working in an expected way (up to some point).
So, I think it detects the wrong (not working) RPC during its construction and it has a way of checking it properly.
I've tried to add the localhost network ran by Ganache provided within MM Extension configuration (in package.json) and I was able to add and use the local blockchain network.

I've noticed that some of the errors can occur in the console of the app while they're also displayed in the Network tab and logged as failed requests. So, I think it's not always going through the background process, since I was using the main app console and network tab rather than background.

Here is an example of adding the provided RPC URL without running blockchain network on localhost (on that port, etc):
Screenshot from 2022-01-11 14-36-29

Screenshot from 2022-01-11 14-33-09

And here is the video where I was experimenting with local blockchain running with Ganache and where I was entering some invalid ports and invalid chain ids:
https://user-images.githubusercontent.com/13301024/148954488-93aee0e8-810d-431d-a58d-075596770b47.mp4

The only thing I've noticed that might be incorrect is when I try to edit the network and put some invalid RPC instead of the valid one that I've added previously. In that case, it will takeover the form and return the valid RPC and network configuration as it was before.

We would appreciate getting more information on this and some acceptance criteria about what would need to be changed or investigated in the given scenario. Thanks.

//cc @danjm @danfinlay

@danjm
Copy link
Contributor

danjm commented Jan 13, 2022

@EHaracic I am removing this from the PS Team backlog for now. Given the difficulty in reproduction it is not important, and your findings so far are very helpful.

@moza88
Copy link

moza88 commented Apr 24, 2022

I am experiencing a similar issue when I try to add my localhost network.
image

I stood up my localhost instance using hardhat, I know hardhat has another chainID so in the hardhat.config file I explicitly set the chainID to 1337 like the following:

export default {
  solidity: "0.8.4",
  networks: {
    hardhat: {
      chainId: 1337
    },
    ropsten: {
      chainId: 3,
      url: `https://eth-ropsten.alchemyapi.io/v2/${process.env.ALCHEMY_API_KEY}`,
      accounts:
        // quick hack to get around changeme being an invalid private key
        process.env.ROPSTEN_PRIVATE_KEY !== "changeme"
          ? [process.env.ROPSTEN_PRIVATE_KEY]
          : []
    }
  }
}

Is there any way to bypass this validation field? Or double-check that the chainID is correct?

@seaona
Copy link
Contributor

seaona commented May 4, 2022

I am getting the same problem. The form behaves quite strangely as it keeps updating the chainId.

I have a geth node running with Rinkeby and every x seconds, Metamask updates the form to 1337 chainId, even though I change it to 4. Everytime I change it, I get the "could not fetch chain Id". See below:

chainId.mp4

@tibbarytsur
Copy link

Not sure if this is still being tracked, but for anyone having this problem this seems to be a problem with Firefox HTTPS-Only mode.

If you enable Firefox' HTTPS-Only mode (even if you set your node's RPC endpoint in the exception list) Firefox forcefully upgrades the connection to HTTPS to check CORS, which fails if your endpoint doesn't support HTTPS.
Note that the OPTION request to the node for checking CORS seems to be cached, so you don't always see that request.

Also the CORS setting of your node needs to allow the MetaMask extension. In the case of Erigon you can do this by adding the --http.corsdomain=moz-extension://1eb35aab-28b1-49f5-b8ab-189f1b09c0f5 commandline option (or --http.corsdomain=* if you want to allow everything.

So the solutions is:

  • either disable HTTP-Only mode completely in Firefox or configure HTTPS on your node.
  • add the correct CORS setting to your node's configuration.

@vpintorico vpintorico added team-extension-platform Sev3-low Low severity; minimal to no impact upon users and removed Sev2-normal Normal severity; minor loss of service or inconvenience. labels Apr 25, 2023
@kugguk2022
Copy link

How can i add my network and blockexplorer to metamask via chainlist.org? i made a fork, kept doing pull requests but i never can add my rcp url chain ID to chainlist.org, edit .jsons with my data, etc...the pull requests dissapear in hours. In ganache i can set values but at metamask the chainID gives me the error https://github.com/MetaMask/metamask-extension/issues/. I dont know why is everything denied/deleted

@github-actions
Copy link
Contributor

This issue has been automatically marked as stale because it has not had recent activity in the last 90 days. It will be closed in 45 days if there is no further activity. The MetaMask team intends on reviewing this issue before close, and removing the stale label if it is still a bug. We welcome new comments on this issue. We do not intend on closing issues if they report bugs that are still reproducible. Thank you for your contributions.

@github-actions github-actions bot added the stale issues and PRs marked as stale label Aug 30, 2023
@nhmartens
Copy link

I experience the same problem with Metamask in Firefox. However, I am not trying to add a local node but a regular testnet. Using Chrome I could add it, but in Firefox I always get the error "Could not fetch chain ID. Is your RPC URL correct?"

@github-actions github-actions bot removed the stale issues and PRs marked as stale label Sep 19, 2023
Copy link
Contributor

This issue has been automatically marked as stale because it has not had recent activity in the last 90 days. It will be closed in 45 days if there is no further activity. The MetaMask team intends on reviewing this issue before close, and removing the stale label if it is still a bug. We welcome new comments on this issue. We do not intend on closing issues if they report bugs that are still reproducible. Thank you for your contributions.

@github-actions github-actions bot added the stale issues and PRs marked as stale label Dec 18, 2023
Copy link
Contributor

github-actions bot commented Feb 1, 2024

This issue was closed because there has been no follow up activity in the last 45 days. If you feel this was closed in error, please reopen and provide evidence on the latest release of the extension. Thank you for your contributions.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Feb 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-customNetworks Sev3-low Low severity; minimal to no impact upon users stale issues and PRs marked as stale team-extension-platform type-bug
Projects
None yet
Development

No branches or pull requests

10 participants