Skip to content

Commit a2f3b39

Browse files
Retry timeouts or connection failures
1 parent d709a88 commit a2f3b39

File tree

1 file changed

+1
-12
lines changed

1 file changed

+1
-12
lines changed

src/agent/api.rs

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ use reqwest::header::AUTHORIZATION;
1111
use reqwest::{Method, StatusCode};
1212
use serde::de::DeserializeOwned;
1313
use serde_json::json;
14-
use std::error::Error as _;
1514

1615
#[derive(Debug, Fail)]
1716
pub enum AgentApiError {
@@ -93,17 +92,7 @@ impl AgentApi {
9392
let retry = if let Some(AgentApiError::ServerUnavailable) = err.downcast_ref() {
9493
true
9594
} else if let Some(err) = err.downcast_ref::<::reqwest::Error>() {
96-
let reqwest_io = err
97-
.source()
98-
.map(|inner| inner.is::<::std::io::Error>())
99-
.unwrap_or(false);
100-
let hyper_io = err
101-
.source()
102-
.and_then(|inner| inner.downcast_ref::<::hyper::Error>())
103-
.and_then(|inner| inner.source())
104-
.map(|inner| inner.is::<::std::io::Error>())
105-
.unwrap_or(false);
106-
reqwest_io || hyper_io
95+
err.is_timeout() || err.is_connect()
10796
} else {
10897
false
10998
};

0 commit comments

Comments
 (0)