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

MetaMask - RPC Error: header not found #7234

Closed
tonoyandev opened this issue Sep 30, 2019 · 58 comments
Closed

MetaMask - RPC Error: header not found #7234

tonoyandev opened this issue Sep 30, 2019 · 58 comments
Labels
area-Infura Sev2-normal Normal severity; minor loss of service or inconvenience. stale issues and PRs marked as stale type-bug

Comments

@tonoyandev
Copy link

I don't launched a project for a 5 days and everything works fine. But now the calls like web3.eth.getBalance or contract methods returns:

{code: -32000, message: "header not found"}

Does anything changed during this period, what the header means? Will appreciate your help, thanks in advance.

@tmashuang
Copy link
Contributor

Please provide additional information that could help reproduce your issue. For example code snippets, browser/OS versions, and console/network logs could help explain your issue.

@Gudahtt
Copy link
Member

Gudahtt commented Mar 17, 2020

I was able to reproduce this bug. It appears to fail intermittently. This us to a bug with Infura (apparently related to load balancing) - they have a fix in development, but it's still broken in prod at the moment.

In the meantime I'd suggest retrying any requests that fail with this error

@owocki
Copy link

owocki commented Mar 23, 2020

im also seeing this issue today. was there ever another ticket created with infura for this?

@peculiarity
Copy link

This issue has been causing us some trouble for the past couple of days.
Can someone prioritize it ?

@x5engine
Copy link

x5engine commented Mar 24, 2020

what is happening?
seems this error code -32000 is

            "-32000": {
                standard: "EIP 1474",
                message: "Invalid input."
            },

more about the error
ethereum/EIPs#136

code description meaning
-32000 INVALID_VALUE parameter contains invalid value
INVALID_VALUE 0 invalid input, e.g. missing mandatory input

Maybe something about the new version of metamask dropping support for web3

related #7708

image

Do you get this a lot? @owocki @peculiarity

@x5engine
Copy link

Solved it! I was on mainnet and the web3 was set to rinkeby instead so it gave this error!

@crazyrabbitLTC
Copy link

@x5engine Could you explain a bit more what you mean by solved?

I am also getting the same error, It would be great if there was some sort of explanation in the error of what is happening and what the error is.
Screen Shot 2020-03-24 at 11 37 20 AM

@b-pmcg
Copy link

b-pmcg commented Mar 25, 2020

@crazyrabbitLTC not solved. It's still happening with regularity on mainnet. Appears to be a bug with infura as @Gudahtt mentioned, but I don't know more than that.

@charleenfei
Copy link

any update on this issue? We are also experiencing this bug regularly.

@x5engine
Copy link

x5engine commented Apr 6, 2020

the bug happens when you use something not on mainnet To be honest....

@01fbk
Copy link

01fbk commented Apr 29, 2020

The bug is still happening. Working on Ropsten testnet.
Haven't tested on main net, but will do and let you guys know.

@x5engine
Copy link

@01fbk let me know! I am waiting!

@karankiri
Copy link

FYI for anyone facing the same issue. I was facing the similar issue on ropsten network I changed my network to mainnet and back to ropsten everything started to work fine.

@wjmelements
Copy link
Contributor

This error seems to mean that the specified block number is not on geth.

@DannyDelott
Copy link

DannyDelott commented Oct 30, 2020

@karankiri this solved it for me, thank you. I was getting this error when connected to a localnet and needed to switch to mainnet and back for this error to stop throwing.

@defidex
Copy link

defidex commented Dec 7, 2020

I am getting this error. Does anybody have a solution. Thanks in advance.

Error to read Metamask ERC balance: {"code":-32000,"message":"header not found"}

@Gudahtt Gudahtt added the Sev2-normal Normal severity; minor loss of service or inconvenience. label Jan 7, 2021
@hazae41
Copy link

hazae41 commented Mar 5, 2021

Bump; the error still happens when using getBalance()

@ChristBKK
Copy link

Error still comes quite often any idea how to solve it?

@mikevercoelen
Copy link

Also seeing this problem often

@cthr
Copy link

cthr commented Mar 22, 2021

currently getting this error frequently too, has something happened recently to cause this?

issue now appears to have resolved itself, perhaps it was an issue with the rpc node metamask was using...

@Padraic-O-Mhuiris
Copy link

This error code is something I have come across frequently in the past and has cropped up again for a project my team is working on. Our current solution is to drop using the MM provider for reading data from ethereum and use a dedicated endpoint directly to infura/alchemy. The issue we experience is that these errors coincide with data not being fetched when connected through the MM provider and using the same address. It does not seem to matter whether it is kovan or mainnet.

In more detail, the issue we are experiencing populates our logs as many have indicated further up the thread. The trace indicates it comes from inpage.js, a file part of the metamask extension and the error code, after trawling through the minified code in the extension indicates these requests providing invalidInput

image

For reference the json-rpc specification reserves -32000 for implementation defined errors
image

This invalidInput could mean potentially a few things but one thing to rule out is that from rigorous testing it is not caused by incorrect input to contract calls and must be resulting between MM and the infura connection it uses.

I don't have any conclusive idea as to what is causing this but I have a gut feeling that it could be throttling. I say this as I have been able monitor the network traffic of the MM extension and the requests are being made to infura and responding without error as shown below.

image

The project does make a relatively large amount of requests, ~1000/min which in our experience has caused the issue to surface quickly compared to other projects.

MM must have some form of backend which monitors the transaction data so that it can validate txs failing or not, I'm sure many who have used MM have observed this before signing. The question is that is there an intermediary backend between client & node which is used to monitor data fetches or at least throttles after heavy usage?
One interesting observation is that while receiving these -32000 errors and potentially being throttled, switching to another address in the same extension worked without issue. Switching back to the first address resulted in the errors again.

It would be appreciated if someone from MM could comment on the issue as it has been over 2 years since this issue has been flagged with little to no response

@Spareo
Copy link

Spareo commented Dec 3, 2021

This started happening to me today with Metamask on Chrome as well. I am unable to load anything and just see this being printed into the console over and over:

code: -32603
data: {code: -32000, message: 'header not found'}
message: "Internal JSON-RPC error."
[[Prototype]]: Object

I also tried from the browser inside the Metamask wallet app on iOS and I get the same result.

@ZaidAhed-Halim
Copy link

i also trying to deploy on Binance smart chain and this issue is still showing

@luncht1me
Copy link

luncht1me commented Jan 8, 2022

This error is likely due to the web3 app you're on is using Infura for RPC service...

Infura is the major web3-rpc gateway and is hosting on AWS... and it has been choking out lately LOL.

@niconiahi
Copy link

would be awesome to have this annoying bug fixed. It dirties the console a lot

@jadbox
Copy link

jadbox commented Feb 22, 2022

Is there any way to auto delay RPC calls with Ethers or something? We've been hitting this issue with Polygon's RPC.

@crazyrabbitLTC
Copy link

crazyrabbitLTC commented Feb 22, 2022 via email

@Ty-Sir
Copy link

Ty-Sir commented Feb 23, 2022

Using ethers.js and a custom node I solved this problem. Instead of relying on metamask (Web3Provider) to make any get calls, I used my custom node from Moralis to make the calls as JsonRpcProvider. You can get a custom node for free at these sites: Alchemy, Infura, Moralis, and Tatum. And $9 per month (7-day free trial) at QuickNode.

const provider = new ethers.providers.JsonRpcProvider("<speedyNodeUrl>");

const instance = new ethers.Contract(<contractAddress>, <abi>, provider);
const data = await instance.getCall();

@Quix44
Copy link

Quix44 commented May 14, 2022

Still an issue all this time later - this time on Fantom, just randomly get this issue with no explanation or no reasoning.

@Stenor5
Copy link

Stenor5 commented Jun 8, 2022

I have the same issue.
Please let me fix this error.

@sdakhara
Copy link

sdakhara commented Aug 4, 2022

I'm also facing the same error on Polygon Mumbai Testnet. When i used the alchemy RPC endpoint in Metamask it just worked fine, i think the issue is with the Public endpoints. They maybe not able to process the request much faster.

@sebastiantf
Copy link

This totally appears to be issues from the RPC health and latency. While monitoring the network and console logs of both MetaMask and the dapp UI, I could find some RPC calls like eth_blockNumber, eth_getBlockByNumber, eth_getBalance, etc. continuously being fired by MetaMask. And some of them, some times return header not found with a 200 OK. The error suggests a particular block (and its header) was not found on the node. The same were logged as errors on the MetaMask console and also re-thrown on the dapp UI console.

I also ran a script to continuously fetch the latest block number and that block. And I was seeing really inconsistent block numbers.

I faced this mostly when using https://matic-mumbai.chainstacklabs.com. I switched to another better RPC like https://polygontestapi.terminet.io/rpc and there were no more errors and the blocks were also consistent.

I also noticed something else. There was an eth_sendRawTransaction RPC call which returned 504 Gateway Timeout. It was followed by a subsequent eth_sendRawTransaction RPC call with the same params, which returned already known. It was thrown on both consoles too.

@benyam7
Copy link

benyam7 commented Aug 25, 2022

I believe the issue relates to the currently selected network in our MetaMask wallet and the network where our smart contract is deployed. So, basically when these two are not matching.

In my case, my smart contract was deployed on Goerli Test Network, but my MetaMask was set to Rinkby Test Network and I am getting this exception when trying to read or write to my smart contract.

  • I solved it by switching to Goerli Test Network, where my smart contract is deployed.

@AntonWeel
Copy link

For others hitting this issue we worked around it by introducing a 100ms delay between RPC requests.

We have such a problem, how to get around it by introducing a delay of 100 ms. delay, you can give a suitable option.

@neuodev
Copy link

neuodev commented Dec 20, 2022

I had this issue this morning on Polygon and It got fixed when I used another RPC! Seems to be RPC issue

@kumavis
Copy link
Member

kumavis commented Jan 19, 2023

this error is associated with running against load balanced rpc endpoints whose nodes are not exactly in sync

@giantdefi
Copy link

For me it was not happen on Main Net. But happen in test net (sometimes happen and not). I tried to call directly from Remix, and when slowly work on remix, then I know the error will appeared on my app. So what is the conclution?

@nestorolivaresh
Copy link

Still having this issue on Ethereum mainnet. I'm calling a smart contract method that returns a view every 5 seconds using ethers. It works fine but after a while this error appears.

I've changed the provider from Infura's public one to Alchemy's private and the error persists. Don't know what to do.

@github-actions
Copy link
Contributor

github-actions bot commented Sep 4, 2023

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 Sep 4, 2023
@github-actions
Copy link
Contributor

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.

@miohtama
Copy link

miohtama commented Feb 2, 2024

I believe it's because JSON-RPC service providers are using load balancers which provide inconsistent view of the blockchain for the user. Or some sort of a similar error. The solution is to have error retry handling on the application level.

Here is an example PR that does it for Python Web3.py:

tradingstrategy-ai/web3-ethereum-defi#201

miohtama added a commit to tradingstrategy-ai/web3-ethereum-defi that referenced this issue Feb 2, 2024
- Whitelist header not found as retryable RPC error
- See discussion MetaMask/metamask-extension#7234
@Abcbef
Copy link

Abcbef commented Nov 24, 2024

Hi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-Infura Sev2-normal Normal severity; minor loss of service or inconvenience. stale issues and PRs marked as stale type-bug
Projects
None yet
Development

No branches or pull requests