MetaMask / metamask-extension

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

MetaMask - RPC Error: header not found #7234

Closed tonoyandev closed 10 months ago

tonoyandev commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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

peculiarity commented 4 years ago

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

x5engine commented 4 years ago

what is happening? seems this error code -32000 is

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

more about the error https://github.com/ethereum/EIPs/issues/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 https://github.com/MetaMask/metamask-extension/issues/7708

image

Do you get this a lot? @owocki @peculiarity

x5engine commented 4 years ago

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

crazyrabbitLTC commented 4 years ago

@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 commented 4 years ago

@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 commented 4 years ago

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

x5engine commented 4 years ago

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

01fbk commented 4 years ago

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

x5engine commented 4 years ago

@01fbk let me know! I am waiting!

karankiri commented 4 years ago

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 commented 4 years ago

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

DannyDelott commented 3 years ago

@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 commented 3 years ago

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"}

hazae41 commented 3 years ago

Bump; the error still happens when using getBalance()

ChristBKK commented 3 years ago

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

mikevercoelen commented 3 years ago

Also seeing this problem often

cthr commented 3 years ago

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 commented 3 years ago

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

AoDev commented 3 years ago

We recently launched on BSC and we have this error showing up often as well.

olegabr commented 3 years ago

Clients have this issue with the https://ethereumico.io/multisend/ service.

sabotagebeats commented 3 years ago

I'm also experiencing this error on BSC.

olegabr commented 3 years ago

Looks like this fixed this problem in my case: address = web3.utils.toChecksumAddress(address.replace("0X", "0x"))

bellaj commented 3 years ago

Switching networks back and forth in Metamask makes the error disappear !!! I got this error when I was resetting the blockchain and trying to reconnect with the same settings.

raulvictorrosa commented 3 years ago

I'm having the same problem here.

dwasyluk commented 2 years ago

Commenting on this bug for every project we encounter it on. Second project this week. Had to introduce artificial delays to the promises calling the contract read functions in order to get around it. Please fix this its really bad.

What's worse is it only seems to present itself on mainnet in my experience.

dwasyluk commented 2 years ago

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

quakemmo commented 2 years ago

On my private clique network, the issue was popping up every time.

Geth was running with --miner.gasprice 1

This made Metamask to use scientific notation in the Send screen as far as gas price was concerned. I started Geth with --miner.gasprice 10000000 and the issue automagically went away.

Hope it fixes it for someone out there.

sundaymorking commented 2 years ago

yeah i got this issue too yesterday .. metamask header not found error nd

anibaljasin commented 2 years ago

had this issue, what solved for me was change the network, I was using the BSC and change it to any another, and go back to BSC and now it works

sentry-io[bot] commented 2 years ago

Sentry issue: METAMASK-J8JZ

kumavis commented 2 years ago

this should help differentiate internal rpc errors https://github.com/MetaMask/eth-json-rpc-middleware/pull/108

goldbock commented 2 years ago

I get the same error on metamask on pancake swap website (liquidity page

x

)

ostar0816 commented 2 years ago

For someone struggling with this kind of RPC error, sometimes headers not found or just Internal RPC Error. Try again after some time...

I was able to fix it by retrying on the above 2 errors via exponential backoff - https://www.npmjs.com/package/retry Usually it succeeds after 1~2 retries, with the default retry count - 5 everything seems working smoothly. Needs to wrap all contract methods with this exponential backoff retry helper unless you use biconomy transactions. I wish it's fixed by infura though.

Hope it helps for someone struggling with it.

sanjuant commented 2 years ago

I have same error, with Ledger Live.

image

Spareo commented 2 years ago

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 commented 2 years ago

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

luncht1me commented 2 years ago

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 commented 2 years ago

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

jadbox commented 2 years ago

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

crazyrabbitLTC commented 2 years ago

What do you mean “auto-delay”?

On Tue, Feb 22, 2022 at 11:24 AM Jonathan Dunlap @.***> wrote:

Is there any way to auto delay RPC calls with Ethers or something?

— Reply to this email directly, view it on GitHub https://github.com/MetaMask/metamask-extension/issues/7234#issuecomment-1047971501, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAOZEXMUCWGKJDPQQ45EEZLU4O2CJANCNFSM4I4AB6JA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you were mentioned.Message ID: @.***>

-- Sent from Gmail Mobile

Quix44 commented 2 years ago

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

Stenor5 commented 2 years ago

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

sdakhara commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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.

AntonWeel commented 1 year ago

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 commented 1 year ago

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