From e87a92efa086f70aef8a8e5d94351b661bfda326 Mon Sep 17 00:00:00 2001 From: Quentin McGaw Date: Sun, 19 Apr 2026 17:48:38 +0000 Subject: [PATCH] hotfix(boringpoll): fix race condition on stop --- internal/boringpoll/boringpoll.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/internal/boringpoll/boringpoll.go b/internal/boringpoll/boringpoll.go index 47abbe7f..8611bf0e 100644 --- a/internal/boringpoll/boringpoll.go +++ b/internal/boringpoll/boringpoll.go @@ -22,7 +22,7 @@ type BoringPoll struct { // Internal signals and channels cancel context.CancelFunc - done <-chan struct{} + done *sync.WaitGroup mutex sync.Mutex } @@ -53,6 +53,7 @@ func (b *BoringPoll) Start() (runError <-chan error, err error) { const logEveryBytes = 100 * 1000 * 1000 // 100 IEC MB var ready, done sync.WaitGroup + b.done = &done ready.Add(len(b.urlToData)) done.Add(len(b.urlToData)) ctx, cancel := context.WithCancel(context.Background()) @@ -166,7 +167,7 @@ func (b *BoringPoll) Stop() error { return nil } b.cancel() - <-b.done + b.done.Wait() b.cancel = nil b.done = nil return nil