From 796073a82d8044d39e51b2bc97b4790bf6cc1124 Mon Sep 17 00:00:00 2001 From: Jordan Krage Date: Mon, 17 Jun 2024 15:51:29 -0500 Subject: [PATCH] common/client: prevent double close of channel (#13571) --- common/client/poller_test.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/common/client/poller_test.go b/common/client/poller_test.go index bd475ef9293..91af579307b 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()