search: fix race condition in doResults
Created by: tsenart
While working on paginated repository resolution, I ran into a weird race in tests. I tracked it down to this classic race bug of closing over a shared loop variable in a go-routine.
Part of #26995 (closed)