Add retry writing to DevFS. (#8142)
This is a workaround to #8141
diff --git a/packages/flutter_tools/lib/src/devfs.dart b/packages/flutter_tools/lib/src/devfs.dart
index 2cd8c09..8ef1931 100644
--- a/packages/flutter_tools/lib/src/devfs.dart
+++ b/packages/flutter_tools/lib/src/devfs.dart
@@ -222,6 +222,7 @@
final Uri httpAddress;
static const int kMaxInFlight = 6;
+ static const int kMaxRetries = 3;
int _inFlight = 0;
Map<String, DevFSContent> _outstanding;
@@ -256,9 +257,12 @@
}
}
- 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 @@
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++;