Skip to content

Commit c8b5fb7

Browse files
committed
agent: properly retry requests if the server is offline
1 parent 70200f3 commit c8b5fb7

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/agent/api.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,17 @@ impl AgentApi {
9191
let retry = if let Some(AgentApiError::ServerUnavailable) = err.downcast_ref() {
9292
true
9393
} else if let Some(err) = err.downcast_ref::<::reqwest::Error>() {
94-
err.cause()
95-
.map(|cause| cause.downcast_ref::<::std::io::Error>().is_some())
96-
.unwrap_or(false)
94+
let reqwest_io = err
95+
.get_ref()
96+
.map(|inner| inner.is::<::std::io::Error>())
97+
.unwrap_or(false);
98+
let hyper_io = err
99+
.get_ref()
100+
.and_then(|inner| inner.downcast_ref::<::hyper::Error>())
101+
.and_then(|inner| inner.cause2())
102+
.map(|inner| inner.is::<::std::io::Error>())
103+
.unwrap_or(false);
104+
reqwest_io || hyper_io
97105
} else {
98106
false
99107
};

0 commit comments

Comments
 (0)