Skip to content

Commit 8ac2944

Browse files
authored
Retry HTTP requests when they fail due to IO errors (#1835)
Closes #1826
1 parent dbe8be2 commit 8ac2944

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

lib/src/http.dart

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,13 @@ final httpClient = new ThrottleClient(
228228
new _ThrowingClient(new RetryClient(_pubClient,
229229
retries: 5,
230230
when: (response) => const [502, 503, 504].contains(response.statusCode),
231+
whenError: (error, stackTrace) {
232+
if (error is! IOException) return false;
233+
234+
var chain = new Chain.forTrace(stackTrace);
235+
log.io("HTTP error:\n$error\n\n${chain.terse}");
236+
return true;
237+
},
231238
delay: (retryCount) {
232239
if (retryCount < 3) {
233240
// Retry quickly a couple times in case of a short transient error.

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ dependencies:
1515
glob: "^1.0.0"
1616
http: "^0.11.0"
1717
http_multi_server: ">=1.0.0 <3.0.0"
18-
http_retry: "^0.1.0"
18+
http_retry: "^0.1.1"
1919
http_throttle: "^1.0.0"
2020
json_rpc_2: "^2.0.0"
2121
meta: "^1.1.0"

0 commit comments

Comments
 (0)