From 698f0a47f365a138007f8b564ceaa5cbdd57e4ca Mon Sep 17 00:00:00 2001 From: Ethan Reesor Date: Mon, 23 Sep 2024 16:12:46 -0500 Subject: [PATCH] Healing fix --- tools/cmd/debug/heal_common.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tools/cmd/debug/heal_common.go b/tools/cmd/debug/heal_common.go index 97ab67756..82910ba1f 100644 --- a/tools/cmd/debug/heal_common.go +++ b/tools/cmd/debug/heal_common.go @@ -101,6 +101,10 @@ func (h *healer) Reset() { } func (h *healer) heal(args []string) { + // Wait must be called after cancel (so the defer must happen first) + wg := new(sync.WaitGroup) + defer wg.Wait() + ctx := cmdutil.ContextForMainProcess(context.Background()) ctx, cancel, _ := api.ContextWithBatchData(ctx) defer cancel() @@ -177,9 +181,6 @@ func (h *healer) heal(args []string) { }, } - wg := new(sync.WaitGroup) - defer wg.Wait() - h.submit = make(chan []messaging.Message) wg.Add(1) go h.submitLoop(wg)