-
Notifications
You must be signed in to change notification settings - Fork 28.7k
[flutter_tools] Add timeout duration to error and handle exceptions for HttpHostValidator. #98290
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
[flutter_tools] Add timeout duration to error and handle exceptions for HttpHostValidator. #98290
Conversation
|
||
final List<_HostValidationResult> availabilityResults = | ||
(await Future.wait(availabilityResultFutures)).toList(); | ||
final List<_HostValidationResult> availabilityResults = await Future.wait(_requiredHosts.map(_checkHostAvailability)); |
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.
Not sure why the .toList
was needed here
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.
Why did you condense lines 89-92 into one? I feel like it is more difficult to read as a one-liner.
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.
So should I reintroduce availabilityResultFutures
?
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 it was just a style refactor, I would prefer having availabilityResultFutures
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 agree that .toList()
was redundant
This pull request has been changed to a draft. The currently pending flutter-gold status will not be able to resolve until a new commit is pushed or the change is marked ready for review again. For more guidance, visit Writing a golden file test for Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
69f00bb
to
fbf784e
Compare
return _HostValidationResult.success(host); | ||
} on TimeoutException { | ||
return _HostValidationResult.fail( | ||
host, 'Failed to connect to $host in seconds'); |
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.
We already mention $host
before this message, no need to mention it again.
} on HttpException catch (e) { | ||
return _HostValidationResult.fail(host, | ||
'An error occurred while checking the HTTP host: ${e.toString()}'); | ||
return _HostValidationResult.fail(host, 'An error occurred while checking the HTTP host: ${e.message}'); |
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.
e.toString() => e.message
expect(result.type, equals(ValidationType.notAvailable)); | ||
} | ||
}); | ||
|
||
testWithoutContext('one http hosts are not available', () async { |
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.
Duplicate test
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.
yikes, good catch
} | ||
}); | ||
|
||
testWithoutContext('one http hosts are not available', () async { |
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.
Duplicate test
1140d90
to
3e6c6fb
Compare
try { | ||
final int timeout = | ||
int.parse(_platform.environment[kDoctorHostTimeout] ?? '10'); | ||
timeout = int.parse(_platform.environment[kDoctorHostTimeout] ?? '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.
can this also be lifted outside of the try block?
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 can't, see #98328.
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.
Are you catching FormatException
?
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.
Not in this PR, but in the (future)PR that fixes that issue, and I see no point in moving this line when eventually it has to be moved back.
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.
any reason not to catch and toolexit on formatexception in this PR?
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.
Nothing specific, thought it would be better to land separate PRs to fix separate issues, but I can include all in one if you are okay with that.
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.
Sounds good to me as long as it's not a lot more code, which I imagine it wouldn't be?
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.
@christopherfujino I've pushed a commit that handles all possible exceptions, PTAL.
3e6c6fb
to
2aa5a65
Compare
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
a4061bd
to
cbde691
Compare
cbde691
to
6c4cd61
Compare
This pull request is not suitable for automatic merging in its current state.
|
@Jasguerrero can you give another review on this one? |
…ptions for HttpHostValidator. (flutter/flutter#98290)
…ptions for HttpHostValidator. (flutter/flutter#98290)
…ptions for HttpHostValidator. (flutter/flutter#98290)
…ptions for HttpHostValidator. (flutter/flutter#98290)
…ptions for HttpHostValidator. (flutter/flutter#98290)
…ptions for HttpHostValidator. (flutter/flutter#98290)
…ptions for HttpHostValidator. (flutter/flutter#98290)
…ptions for HttpHostValidator. (flutter/flutter#98290)
…ptions for HttpHostValidator. (flutter/flutter#98290)
…ptions for HttpHostValidator. (flutter/flutter#98290)
…ptions for HttpHostValidator. (flutter/flutter#98290)
…ptions for HttpHostValidator. (flutter/flutter#98290)
…ptions for HttpHostValidator. (flutter/flutter#98290)
…ptions for HttpHostValidator. (flutter/flutter#98290)
…ptions for HttpHostValidator. (flutter/flutter#98290)
…ptions for HttpHostValidator. (flutter/flutter#98290)
…ptions for HttpHostValidator. (flutter/flutter#98290)
…ptions for HttpHostValidator. (flutter/flutter#98290)
…ptions for HttpHostValidator. (flutter/flutter#98290)
…ptions for HttpHostValidator. (flutter/flutter#98290)
…ptions for HttpHostValidator. (flutter/flutter#98290)
…ptions for HttpHostValidator. (flutter/flutter#98290)
…ptions for HttpHostValidator. (flutter/flutter#98290)
…ptions for HttpHostValidator. (flutter/flutter#98290)
…ptions for HttpHostValidator. (flutter/flutter#98290)
…ptions for HttpHostValidator. (flutter/flutter#98290)
…ptions for HttpHostValidator. (flutter/flutter#98290)
…ptions for HttpHostValidator. (flutter/flutter#98290)
Includes the timeout duration, handles exceptions for invalid
FLUTTER_DOCTOR_HOST_TIMEOUT
,PUB_HOSTED_URL
orFLUTTER_STORAGE_BASE_URL
environment variables ofHttpHostValidator
.Also includes some code hand-formatting/cleanup for readability.
Adds tests to make sure the timeout is being displayed and exceptions are handled accordingly.
Fixes #98286.
Fixes #98328.
Pre-launch Checklist
///
).If you need help, consider asking for advice on the #hackers-new channel on Discord.