Skip to content

Conversation

@aam
Copy link
Member

@aam aam commented Sep 26, 2019

Fixes #34959.

@fluttergithubbot
Copy link
Contributor

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.

@fluttergithubbot fluttergithubbot added the tool Affects the "flutter" command-line tool. See also t: labels. label Sep 26, 2019
@codecov
Copy link

codecov bot commented Sep 26, 2019

Codecov Report

Merging #41406 into master will increase coverage by 0.99%.
The diff coverage is 87.5%.

Impacted file tree graph

@@            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
Flag Coverage Δ
#flutter_tool 60.42% <87.5%> (+0.99%) ⬆️
Impacted Files Coverage Δ
packages/flutter_tools/lib/src/devfs.dart 69.9% <87.5%> (+1.09%) ⬆️
...s/flutter_tools/lib/src/commands/build_bundle.dart 86.53% <0%> (-11.54%) ⬇️
packages/flutter_tools/lib/src/run_cold.dart 9.75% <0%> (-9.76%) ⬇️
...ges/flutter_tools/lib/src/build_runner/web_fs.dart 21.69% <0%> (-2.93%) ⬇️
packages/flutter_tools/lib/src/build_info.dart 75.13% <0%> (-1.63%) ⬇️
packages/flutter_tools/lib/src/version.dart 91.9% <0%> (-1.43%) ⬇️
packages/flutter_tools/lib/src/cache.dart 45.31% <0%> (-0.67%) ⬇️
packages/flutter_tools/lib/src/commands/run.dart 64.39% <0%> (-0.49%) ⬇️
packages/flutter_tools/lib/src/vmservice.dart 40.56% <0%> (-0.34%) ⬇️
packages/flutter_tools/lib/src/project.dart 84.76% <0%> (-0.05%) ⬇️
... and 9 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0980fa2...c1d0550. Read the comment docs.

@aam aam requested a review from jonahwilliams September 29, 2019 21:30
Copy link
Contributor

@jonahwilliams jonahwilliams left a 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((_) {
Copy link
Contributor

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.

Suggested change
when(httpRequest.close()).thenAnswer((_) {
when(httpRequest.close()).thenAnswer((Invocation invocation) {

Copy link
Member Author

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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: no screaming caps

Suggested change
const int FAILED_ATTEMPTS = 5;
const int kFailedAttempts = 5;

Copy link
Member Author

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) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (nRequest++ < FAILED_ATTEMPTS) {
if (nRequest++ < kFailedAttempts) {

Copy link
Member Author

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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
verify(httpClient.putUrl(any)).called(FAILED_ATTEMPTS + 1);
verify(httpClient.putUrl(any)).called(kFailedAttempts + 1);

Copy link
Member Author

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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
verify(httpRequest.close()).called(FAILED_ATTEMPTS + 1);
verify(httpRequest.close()).called(kFailedAttempts + 1);

Copy link
Member Author

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);
Copy link
Contributor

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.

Suggested change
_startWrite(deviceUri, content, /* retry= */ 10);
_startWrite(deviceUri, content, retry: 10);

Copy link
Member Author

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, [
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
DevFSContent content, [
DevFSContent content, {
int retry = 0
}

Copy link
Member Author

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) {
Copy link
Contributor

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

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Contributor

@jonahwilliams jonahwilliams left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@aam aam merged commit 839fdbd into flutter:master Sep 30, 2019
@aam aam deleted the retry-devfs-upload branch September 30, 2019 04:32
@aam
Copy link
Member Author

aam commented Sep 30, 2019

Thanks!

Glad to help!

@tvolkert
Copy link
Contributor

Do we know why the devfs writes were failing?

@aam
Copy link
Member Author

aam commented Sep 30, 2019

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.

Inconnu08 pushed a commit to Inconnu08/flutter that referenced this pull request Sep 30, 2019
* Retry devfs uploads in case they fail.

Fixes flutter#34959.
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 4, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

During development, Flutter app on iOS occasionally won't launch

5 participants