fix race from leaked goroutine
Created by: camdencheek
We were leaking a goroutine in an optimization to move logging latency out of the critical path of streaming search, so this collects that goroutine while still allowing it to run concurrently. I added the waitgroup as part of the function signature to make it harder to misuse (as opposed to a return value that could be ignored).
Fixes https://github.com/sourcegraph/sourcegraph/issues/30426