clean up rate limit logging
This commit is contained in:
parent
b476a56ad6
commit
78c6179f02
@ -902,7 +902,11 @@ impl Web3Rpcs {
|
||||
let rate_limit_substrings = ["limit", "exceeded", "quota usage"];
|
||||
for rate_limit_substr in rate_limit_substrings {
|
||||
if error_msg.contains(rate_limit_substr) {
|
||||
if error_msg.contains("result on length") {
|
||||
if error_msg.contains("block size") {
|
||||
// TODO: this message is likely wrong, but i can't find the actual one in my terminal now
|
||||
// they hit an expected limit. return the error now
|
||||
return Err(error.into());
|
||||
} else if error_msg.contains("result on length") {
|
||||
// this error contains "limit" but is not a rate limit error
|
||||
// TODO: make the expected limit configurable
|
||||
// TODO: parse the rate_limit_substr and only continue if it is < expected limit
|
||||
@ -910,10 +914,10 @@ impl Web3Rpcs {
|
||||
// they hit our expected limit. return the error now
|
||||
return Err(error.into());
|
||||
} else {
|
||||
// they hit a limit lower than what we expect
|
||||
warn!(
|
||||
// they hit a limit lower than what we expect. the server is misconfigured
|
||||
error!(
|
||||
%error_msg,
|
||||
"unexpected result limitby {}",
|
||||
"unexpected result limit by {}",
|
||||
skip_rpcs.last().unwrap(),
|
||||
);
|
||||
continue;
|
||||
|
@ -965,6 +965,8 @@ impl Web3Rpc {
|
||||
max_wait: Option<Duration>,
|
||||
error_handler: Option<RequestErrorHandler>,
|
||||
) -> Web3ProxyResult<OpenRequestHandle> {
|
||||
// TODO: what should the default be?
|
||||
// TODO: split max_wait_connect (which might wait if a rate limit is pending) and max_wait_request
|
||||
let max_wait_until = max_wait.map(|x| Instant::now() + x);
|
||||
|
||||
loop {
|
||||
|
@ -273,12 +273,6 @@ impl OpenRequestHandle {
|
||||
trace!("revert from {}", self.rpc);
|
||||
ResponseTypes::Revert
|
||||
} else if msg.contains("limit") || msg.contains("request") {
|
||||
// TODO: too verbose
|
||||
if self.rpc.backup {
|
||||
trace!(%msg, "rate limit from {}", self.rpc);
|
||||
} else {
|
||||
warn!(%msg, "rate limit from {}", self.rpc);
|
||||
}
|
||||
ResponseTypes::RateLimit
|
||||
} else {
|
||||
ResponseTypes::Error
|
||||
@ -295,16 +289,13 @@ impl OpenRequestHandle {
|
||||
// TODO: how long should we actually wait? different providers have different times
|
||||
// TODO: if rate_limit_period_seconds is set, use that
|
||||
// TODO: check response headers for rate limits too
|
||||
// TODO: warn if production, debug if backup
|
||||
if self.rpc.backup {
|
||||
debug!("unexpected rate limit on {}!", self.rpc);
|
||||
} else {
|
||||
warn!("unexpected rate limit on {}!", self.rpc);
|
||||
}
|
||||
|
||||
let retry_at = Instant::now() + Duration::from_secs(1);
|
||||
|
||||
trace!("retry {} at: {:?}", self.rpc, retry_at);
|
||||
if self.rpc.backup {
|
||||
debug!(?retry_at, "rate limited on {}!", self.rpc);
|
||||
} else {
|
||||
warn!(?retry_at, "rate limited on {}!", self.rpc);
|
||||
}
|
||||
|
||||
hard_limit_until.send_replace(retry_at);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user