Skip to content

Commit

Permalink
fix: also try error payload response (#7264)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattsse authored Feb 28, 2024
1 parent 6ca3734 commit 485a0d6
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions crates/common/src/provider/retry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ impl RetryPolicy for RateLimitRetryPolicy {
// the start.
TransportError::SerError(_) => false,
TransportError::DeserError { text, .. } => {
if let Ok(resp) = serde_json::from_str::<ErrorPayload>(text) {
return should_retry_json_rpc_error(&resp)
}

// some providers send invalid JSON RPC in the error case (no `id:u64`), but the
// text should be a `JsonRpcError`
#[derive(Deserialize)]
Expand All @@ -41,6 +45,7 @@ impl RetryPolicy for RateLimitRetryPolicy {
if let Ok(resp) = serde_json::from_str::<Resp>(text) {
return should_retry_json_rpc_error(&resp.error)
}

false
}
TransportError::ErrorResp(err) => should_retry_json_rpc_error(err),
Expand Down

0 comments on commit 485a0d6

Please sign in to comment.