diff --git a/common/client/poller_test.go b/common/client/poller_test.go index bd475ef929..91af579307 100644 --- a/common/client/poller_test.go +++ b/common/client/poller_test.go @@ -120,8 +120,9 @@ func Test_Poller(t *testing.T) { t.Run("Test unsubscribe during polling", func(t *testing.T) { wait := make(chan struct{}) + closeOnce := sync.OnceFunc(func() { close(wait) }) pollFunc := func(ctx context.Context) (Head, error) { - close(wait) + closeOnce() // Block in polling function until context is cancelled if <-ctx.Done(); true { return nil, ctx.Err()