From d8a3371a4ba5ecd3a3e6eceeca93b35650f1ec55 Mon Sep 17 00:00:00 2001 From: Leander Beernaert Date: Thu, 4 May 2023 10:22:24 +0200 Subject: [PATCH] fix: Defer wg.Done() in Group.Once() Always defer wait group done on the goroutine to avoid stalls in case of panics. --- async/group.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/async/group.go b/async/group.go index 7e045d95..3e3d4b5e 100644 --- a/async/group.go +++ b/async/group.go @@ -46,8 +46,9 @@ func (g *Group) Once(f func(ctx context.Context)) { go func() { defer HandlePanic(g.panicHandler) + defer g.wg.Done() + f(g.ctx) - g.wg.Done() }() }