Skip to content

Commit

Permalink
fix: Defer wg.Done() in Group.Once()
Browse files Browse the repository at this point in the history
Always defer wait group done on the goroutine to avoid stalls in case
of panics.
  • Loading branch information
LBeernaertProton committed May 4, 2023
1 parent 2797a17 commit d8a3371
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion async/group.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}()
}

Expand Down

0 comments on commit d8a3371

Please sign in to comment.