From 06a05f540f0735958c4839a9ebce1b71cdbb6eb4 Mon Sep 17 00:00:00 2001 From: Stuart Douglas Date: Mon, 23 Sep 2024 16:22:25 +1000 Subject: [PATCH] fix: stack trace exiting interactive console (#2786) --- internal/console/status.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/internal/console/status.go b/internal/console/status.go index ef74a4e09a..f84f0c8fd1 100644 --- a/internal/console/status.go +++ b/internal/console/status.go @@ -119,8 +119,8 @@ func NewStatusManager(ctx context.Context) StatusManager { }() go func() { - defer sm.exitWait.Done() current := "" + closed := false for { buf := bytes.Buffer{} @@ -130,6 +130,9 @@ func NewStatusManager(ctx context.Context) StatusManager { if current != "" { sm.writeLine(current) } + if !closed { + sm.exitWait.Done() + } return } buf.Write(rawData[:n]) @@ -140,7 +143,10 @@ func NewStatusManager(ctx context.Context) StatusManager { // we keep running though as there may be more data on exit // that we handle on a best effort basis sm.writeLine(current) - sm.exitWait.Done() + if !closed { + sm.exitWait.Done() + closed = true + } continue } if err != nil {