From 7e43cae1bbd173bf7a255b716ff794dc90fe14ce Mon Sep 17 00:00:00 2001 From: Adam Pitt Date: Tue, 22 Aug 2023 09:54:12 +1000 Subject: [PATCH] Fix race condition issue in combineLatest --- factory.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/factory.go b/factory.go index a3e18dad..6f249386 100644 --- a/factory.go +++ b/factory.go @@ -93,10 +93,10 @@ func CombineLatest(f FuncN, observables []Observable, opts ...Option) Observable errCh <- struct{}{} return } + mutex.Lock() if s[i] == nil { atomic.AddUint32(&counter, 1) } - mutex.Lock() s[i] = item.V if atomic.LoadUint32(&counter) == size { next <- Of(f(s...))