diff --git a/shards/shards.go b/shards/shards.go index 0e3672745..2977cc0b8 100644 --- a/shards/shards.go +++ b/shards/shards.go @@ -919,6 +919,20 @@ func (ss *shardedSearcher) List(ctx context.Context, r query.Q, opts *zoekt.List tr.LazyPrintf("acquired process") loaded := ss.getLoaded() + + // Setup what we return now, since we may short circuit if there are no + // shards to search. + stillLoadingCrashes := 0 + if !loaded.ready { + // We may have missed results due to not being fully loaded. + stillLoadingCrashes++ + } + agg := zoekt.RepoList{ + Crashes: stillLoadingCrashes, + ReposMap: zoekt.ReposMap{}, + Repos: []*zoekt.RepoListEntry{}, + } + shards := loaded.shards shardCount := len(shards) all := make(chan shardListResult, shardCount) @@ -938,17 +952,6 @@ func (ss *shardedSearcher) List(ctx context.Context, r query.Q, opts *zoekt.List }() } - stillLoadingCrashes := 0 - if !loaded.ready { - // We may have missed results due to not being fully loaded. - stillLoadingCrashes++ - } - - agg := zoekt.RepoList{ - Crashes: stillLoadingCrashes, - ReposMap: zoekt.ReposMap{}, - } - uniq := map[string]*zoekt.RepoListEntry{} for range shards {