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

[Bug]: Periodical errors when using RPC gateways #18467

Closed
andrew-webatix opened this issue Apr 5, 2023 · 5 comments
Closed

[Bug]: Periodical errors when using RPC gateways #18467

andrew-webatix opened this issue Apr 5, 2023 · 5 comments
Labels
needs-reproduction Sev2-normal Normal severity; minor loss of service or inconvenience. stale issues and PRs marked as stale team-extension-platform type-bug

Comments

@andrew-webatix
Copy link

Describe the bug

In our application we are using https://polygon-rpc.com - RPC gateway that relies on globally distributed nodes. Sometimes that gateway switches from one node to another where the last block number is less than in previous node. If in this case we are trying to perform a call to some smart contract method (e.g. 'balanceOf' of the ERC20 token):

  1. MetaMask will request the last block number from the first node (transparently of course) and get actual value;
  2. Then RPC gateway may switch us to the different node with lesser height (last block number);
  3. Which then lead to an error, as result of such a request will be '0x'.

MetaMask itself do not treat '0x' as an error and successfully caches this value as a valid result of a call. We are using Ethers library in our application, which actually treat '0x' result as a BAD_DATA error. And this BAD_DATA can stay there for up to 20 seconds as MetaMask returns cached '0x' result all that time. Obviously our application stuck in such cases.

We suppose that more correct behavior of MetaMask in such situations is to treat '0x' response as an empty value error and perform several retries internally before throwing an actual error. In this case RPC gateway can get a chance to re-route following requests to more suitable node with correct height.

It looks like similar issues were faced already few years ago.. it was claimed to fix as a part of go-ethereum (that was related to Metamask), but have been returned after some major changes:

Couldn't decode _____ from ABI: 0x
Need to throw error when methods are called at future blocks

Potentially this issue can be fixed with patches attached here: patches.zip

Steps to reproduce

Here is the test page which can reproduce the problem: test.zip It performs series of calls (3000 iterations, one per a second) to 'balanceOf' method of arbitrary ERC20 smart contract and address. In most cases it returns valid balance value. But from time to time an error messages can be noticed in DevTools / Console and this error stays there for about 20 seconds (cache lifetime?). Such an errors breaks our application. Test page can be started with use of a simple static HTTP server.
errors-in-console
errors-result

Error messages or log output

No response

Version

10.27.0

Build type

None

Browser

Chrome

Operating system

Linux

Hardware wallet

No response

Additional context

No response

@danjm danjm added Sev2-normal Normal severity; minor loss of service or inconvenience. needs-reproduction team-unkown labels Apr 28, 2023
@danjm
Copy link
Contributor

danjm commented Jul 25, 2023

@andrew-webatix Can you share the zip files in another form? For instance, could you post a github repo containing those files?

@andrew-webatix
Copy link
Author

@andrew-webatix Can you share the zip files in another form? For instance, could you post a github repo containing those files?

Sure. All files can be found here: https://github.com/andrew-webatix/metamask-issue-18467

@danjm
Copy link
Contributor

danjm commented Jul 25, 2023

thanks!

@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 Oct 23, 2023
Copy link
Contributor

github-actions bot commented Dec 7, 2023

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 Dec 7, 2023
@github-project-automation github-project-automation bot moved this to To be fixed in Bugs by severity Apr 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-reproduction Sev2-normal Normal severity; minor loss of service or inconvenience. stale issues and PRs marked as stale team-extension-platform type-bug
Projects
None yet
Development

No branches or pull requests

2 participants