Commit f903a1c8 authored by Todd Volkert's avatar Todd Volkert Committed by GitHub

Add retry writing to DevFS. (#8142)

This is a workaround to #8141
parent 43650e93
......@@ -222,6 +222,7 @@ class _DevFSHttpWriter {
final Uri httpAddress;
static const int kMaxInFlight = 6;
static const int kMaxRetries = 3;
int _inFlight = 0;
Map<String, DevFSContent> _outstanding;
......@@ -256,9 +257,12 @@ class _DevFSHttpWriter {
}
}
Future<Null> _scheduleWrite(String devicePath,
DevFSContent content,
DevFSProgressReporter progressReporter) async {
Future<Null> _scheduleWrite(
String devicePath,
DevFSContent content,
DevFSProgressReporter progressReporter, [
int retry = 0,
]) async {
try {
HttpClientRequest request = await _client.putUrl(httpAddress);
request.headers.removeAll(HttpHeaders.ACCEPT_ENCODING);
......@@ -270,7 +274,13 @@ class _DevFSHttpWriter {
HttpClientResponse response = await request.close();
await response.drain<Null>();
} catch (e) {
printError('Error writing "$devicePath" to DevFS: $e');
if (retry < kMaxRetries) {
printTrace('Retrying writing "$devicePath" to DevFS due to error: $e');
_scheduleWrite(devicePath, content, progressReporter, retry + 1);
return;
} else {
printError('Error writing "$devicePath" to DevFS: $e');
}
}
if (progressReporter != null) {
_done++;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment