Fix potential goroutine leak in operation_executor_test.go

If the test times out in isOperationRunConcurrently, the receiver channel stops listening. The goroutine spawned in startOperationAndBlock then blocks forever on ch <- nil.

This commit updates startOperationAndBlock to use a select statement. It now waits for either the send to complete or the quit channel to be closed (signaling test completion). This ensures the goroutine exits cleanly even if the receiver is gone.

Signed-off-by: kkh <kkhdevs@gmail.com>
This commit is contained in:
kkh 2026-01-05 16:18:27 +09:00
parent 18663b347e
commit d733195cfe

View file

@ -185,6 +185,9 @@ func setup(t *testing.T) (context.Context, chan interface{}, chan interface{}, O
// This function starts by writing to ch and blocks on the quit channel
// until it is closed by the currently running test
func startOperationAndBlock(ch chan<- interface{}, quit <-chan interface{}) {
ch <- nil
<-quit
select {
case ch <- nil:
<-quit
case <-quit:
}
}