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

Detecting rate limiting and transport error codes #565

Open
Mirko-von-Leipzig opened this issue Nov 4, 2021 · 4 comments
Open

Detecting rate limiting and transport error codes #565

Mirko-von-Leipzig opened this issue Nov 4, 2021 · 4 comments

Comments

@Mirko-von-Leipzig
Copy link

Mirko-von-Leipzig commented Nov 4, 2021

I am currently using eth_getLogs and will occasionally get rate limited. This would be indicated by an error code 429.

Judging by this code, this currently gets "exposed" as an error string

Err(Error::Transport(format!(
            "response status code is not success: {}",
            status
        )

Would it be possible to expose the plain code? This would make it far easier to match on.

--edit--
In addition, Infura adds additional information into the body, which would be useful to have. i.e. the number of seconds to backoff.

@tomusdrw
Copy link
Owner

I think ideally this kind of throttling should be handled by the transport layer itself. Obviously I'm also fine with exposing this as a typed error. I think Error::Transport would could hold an enum instead of a String?

@Mirko-von-Leipzig
Copy link
Author

I think ideally this kind of throttling should be handled by the transport layer itself.
I think it can so long as the retry-amount is configurable? I would likely want to log that it happened though.

In general I think exposing the error code and contents in an enum would be fine.

@tomusdrw
Copy link
Owner

tomusdrw commented Feb 2, 2022

Related: #585

@Mirko-von-Leipzig
Copy link
Author

I see 0.18.0 now returns this situation as a TransportError::Code(429) which is great.

One thing that is still missing (I think) is getting the accompanying payload message. Some servers will set the back off time or other useful information.

For example, Infura returns 429 plus a json RPC payload which contains the back off time and current rate-limiting.

Infura rate limit docs: https://docs.infura.io/infura/networks/ethereum/how-to/secure-a-project/set-rate-limits#how-do-i-know-if-im-being-rate-limited

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants