-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Retry devfs uploads in case they fail. #41406
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
It looks like this pull request may not have tests. Please make sure to add tests before merging. While there are exceptions to this rule, if this patch modifies code it is probably not an exception. Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
Codecov Report
@@ Coverage Diff @@
## master #41406 +/- ##
==========================================
+ Coverage 59.43% 60.42% +0.99%
==========================================
Files 193 193
Lines 18758 18755 -3
==========================================
+ Hits 11149 11333 +184
+ Misses 7609 7422 -187
Continue to review full report at Codecov.
|
jonahwilliams
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Thanks for doing all of the work to track this issue down and fix it. I just have a few style nits but otherwise looks good to go.
| final MockHttpClientResponse httpClientResponse = MockHttpClientResponse(); | ||
| int nRequest = 0; | ||
| const int FAILED_ATTEMPTS = 5; | ||
| when(httpRequest.close()).thenAnswer((_) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I'm not sure if the always_specify_types lint will accept _ but it probably shouldn't.
| when(httpRequest.close()).thenAnswer((_) { | |
| when(httpRequest.close()).thenAnswer((Invocation invocation) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
| when(httpClient.putUrl(any)).thenAnswer((_) => Future<HttpClientRequest>.value(httpRequest)); | ||
| final MockHttpClientResponse httpClientResponse = MockHttpClientResponse(); | ||
| int nRequest = 0; | ||
| const int FAILED_ATTEMPTS = 5; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: no screaming caps
| const int FAILED_ATTEMPTS = 5; | |
| const int kFailedAttempts = 5; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
| int nRequest = 0; | ||
| const int FAILED_ATTEMPTS = 5; | ||
| when(httpRequest.close()).thenAnswer((_) { | ||
| if (nRequest++ < FAILED_ATTEMPTS) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| if (nRequest++ < FAILED_ATTEMPTS) { | |
| if (nRequest++ < kFailedAttempts) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
|
|
||
| expect(report.syncedBytes, 22); | ||
| expect(report.success, isTrue); | ||
| verify(httpClient.putUrl(any)).called(FAILED_ATTEMPTS + 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| verify(httpClient.putUrl(any)).called(FAILED_ATTEMPTS + 1); | |
| verify(httpClient.putUrl(any)).called(kFailedAttempts + 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
| expect(report.syncedBytes, 22); | ||
| expect(report.success, isTrue); | ||
| verify(httpClient.putUrl(any)).called(FAILED_ATTEMPTS + 1); | ||
| verify(httpRequest.close()).called(FAILED_ATTEMPTS + 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| verify(httpRequest.close()).called(FAILED_ATTEMPTS + 1); | |
| verify(httpRequest.close()).called(kFailedAttempts + 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
| final Uri deviceUri = _outstanding.keys.first; | ||
| final DevFSContent content = _outstanding.remove(deviceUri); | ||
| _startWrite(deviceUri, content); | ||
| _startWrite(deviceUri, content, /* retry= */ 10); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would update this to a named argument instead of using the comment syntax.
| _startWrite(deviceUri, content, /* retry= */ 10); | |
| _startWrite(deviceUri, content, retry: 10); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
|
|
||
| Future<void> _startWrite( | ||
| Uri deviceUri, | ||
| DevFSContent content, [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| DevFSContent content, [ | |
| DevFSContent content, { | |
| int retry = 0 | |
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
| } catch (error, trace) { | ||
| if (!_completer.isCompleted) { | ||
| printTrace('Error writing "$deviceUri" to DevFS: $error'); | ||
| if (retry-- > 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pre/post increment is a bit weird inline with a >, kind of looks like a giant arrow. I think it would be easier to read if this were split into two lines
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
jonahwilliams
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Glad to help! |
|
Do we know why the devfs writes were failing? |
Only hypothesis is that iproxy that we use to bridge from mac to http server running on the ios device decides to abandon http connection, which is always allowed. Unfortunately it didn't print anything in the logs to explain the reasons. |
* Retry devfs uploads in case they fail. Fixes flutter#34959.
Fixes #34959.