From cf89a1f6ce717662d16b4c4e07d6ccef90171863 Mon Sep 17 00:00:00 2001 From: pancsta <155631569+pancsta@users.noreply.github.com> Date: Thu, 18 Jan 2024 16:58:35 +0100 Subject: [PATCH] fix: prevent double handlerDone notif --- pkg/machine/machine.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/machine/machine.go b/pkg/machine/machine.go index a76081a..1b6fa2f 100644 --- a/pkg/machine/machine.go +++ b/pkg/machine/machine.go @@ -260,7 +260,7 @@ func (m *Machine) When(states []string, ctx context.Context) chan struct{} { setMap[s] = m.Is(S{s}) if setMap[s] { matched++ - } + } } // add the binding to an index of each state binding := &whenBinding{ @@ -974,8 +974,9 @@ func (m *Machine) processEmitters(e *Event) Result { []reflect.Value{reflect.ValueOf(e)}) if len(callRet) > 0 { m.handlerDone <- callRet[0].Interface().(bool) + return } - // handlers returns true by default + // handlers return true by default m.handlerDone <- true }() // wait on the result / timeout / context