-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: retry certain http errors reported by replica during asset uploa…
…ds (#3822)
- Loading branch information
1 parent
2ce92fa
commit 5853140
Showing
2 changed files
with
22 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 13 additions & 4 deletions
17
src/canisters/frontend/ic-asset/src/batch_upload/retryable.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,17 @@ | ||
use ic_agent::agent::http_transport::reqwest_transport::reqwest::StatusCode; | ||
use ic_agent::AgentError; | ||
|
||
pub(crate) fn retryable(agent_error: &AgentError) -> bool { | ||
matches!( | ||
agent_error, | ||
AgentError::TimeoutWaitingForResponse() | AgentError::TransportError(_) | ||
) | ||
match agent_error { | ||
AgentError::TimeoutWaitingForResponse() => true, | ||
AgentError::TransportError(_) => true, | ||
AgentError::HttpError(http_error) => { | ||
http_error.status == StatusCode::INTERNAL_SERVER_ERROR | ||
|| http_error.status == StatusCode::BAD_GATEWAY | ||
|| http_error.status == StatusCode::SERVICE_UNAVAILABLE | ||
|| http_error.status == StatusCode::GATEWAY_TIMEOUT | ||
|| http_error.status == StatusCode::TOO_MANY_REQUESTS | ||
} | ||
_ => false, | ||
} | ||
} |