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

Retry on rpc timeout response #518

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions clients/runtime/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,22 @@ impl Error {
&format!("{:?}", SecurityPalletError::ParachainNotRunning),
)
}

pub fn is_timeout_error(&self) -> bool {
match self {
Error::SubxtRuntimeError(SubxtError::Rpc(RpcError::ClientError(e))) =>
match e.downcast_ref::<JsonRpseeError>() {
Some(e) => matches!(e, JsonRpseeError::RequestTimeout),
None => {
log::error!(
"Failed to downcast RPC error; this is a bug please file an issue"
);
false
},
},
_ => false,
}
}
}

impl RecoverableError {
Expand Down
2 changes: 2 additions & 0 deletions clients/runtime/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,8 @@ impl SpacewalkParachain {
} else if err.is_block_hash_not_found_error() {
log::info!("Re-sending transaction after apparent fork");
Err(RetryPolicy::Skip(Error::BlockHashNotFound))
} else if err.is_timeout_error() {
Err(RetryPolicy::Skip(Error::Timeout))
} else {
Err(RetryPolicy::Throw(err))
}
Expand Down
4 changes: 3 additions & 1 deletion clients/vault/src/oracle/storage/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,9 @@ pub trait ArchiveStorage {
fn remove_file(&self, target_slot: Slot) {
let (_, file) = self.get_url_and_file_name(target_slot);
if let Err(e) = fs::remove_file(&file) {
tracing::warn!("remove_file(): failed to remove file {file} for slot {target_slot}: {e:?}");
tracing::warn!(
"remove_file(): failed to remove file {file} for slot {target_slot}: {e:?}"
);
}
}

Expand Down
2 changes: 2 additions & 0 deletions clients/vault/src/requests/structs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,8 @@ impl Request {
Err(RetryPolicy::Throw(err))
} else if err.is_block_hash_not_found_error() {
Err(RetryPolicy::Skip(EnrichedError::BlockHashNotFound))
} else if err.is_timeout_error() {
Err(RetryPolicy::Skip(EnrichedError::Timeout))
} else {
Err(RetryPolicy::Throw(err))
}
Expand Down
Loading