Skip to content

Adjust search client retry attempts #3426

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

Merged
merged 1 commit into from
Mar 16, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions app/lib/search/search_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,13 @@ class SearchClient {
final String serviceUrl = '$httpHostPort/search$serviceUrlParams';

Future<PackageSearchResult> searchFn() async {
final response = await getUrlWithRetry(_httpClient, serviceUrl,
timeout: Duration(seconds: 5));
final response = await getUrlWithRetry(
_httpClient,
serviceUrl,
timeout: Duration(seconds: 5),
// limit to a single attempt, no need to retry after timeout
retryCount: 0,
Copy link
Member

Choose a reason for hiding this comment

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

We're reusing the _httpClient, so if there are connections in pool, where the remote side has closed down, we get a quick disconnect and we don't retry..

Is that wise?

Another strategy is to retry if the request didn't take 3s. It's quite common for idle TCP connections to have the remote side shutdown, without anyone noticing locally.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

But then we should also discard the _httpClient instance when this happens, as other connections could be stale too. I've filed #3431 to track it.

);
if (response.statusCode == searchIndexNotReadyCode) {
// Search request before the service initialization completed.
return null;
Expand Down