diff --git a/pkg/progress/tty.go b/pkg/progress/tty.go index 293e42b0..5fe4270b 100644 --- a/pkg/progress/tty.go +++ b/pkg/progress/tty.go @@ -38,12 +38,13 @@ type ttyWriter struct { repeated bool numLines int done chan bool - mtx *sync.RWMutex + mtx *sync.Mutex tailEvents []string } func (w *ttyWriter) Start(ctx context.Context) error { ticker := time.NewTicker(100 * time.Millisecond) + defer ticker.Stop() for { select { @@ -188,7 +189,7 @@ func lineText(event Event, pad string, terminalWidth, statusPadding int, color b padding = 0 } // calculate the max length for the status text, on errors it - // is 2-3 lines long and breaks the line formating + // is 2-3 lines long and breaks the line formatting maxStatusLen := terminalWidth - textLen - statusPadding - 15 status := event.StatusText // in some cases (debugging under VS Code), terminalWidth is set to zero by goterm.Width() ; ensuring we don't tweak strings with negative char index diff --git a/pkg/progress/tty_test.go b/pkg/progress/tty_test.go index d95af857..f9b4071d 100644 --- a/pkg/progress/tty_test.go +++ b/pkg/progress/tty_test.go @@ -78,7 +78,7 @@ func TestLineTextSingleEvent(t *testing.T) { func TestErrorEvent(t *testing.T) { w := &ttyWriter{ events: map[string]Event{}, - mtx: &sync.RWMutex{}, + mtx: &sync.Mutex{}, } e := Event{ ID: "id", diff --git a/pkg/progress/writer.go b/pkg/progress/writer.go index 172de52f..11d4044b 100644 --- a/pkg/progress/writer.go +++ b/pkg/progress/writer.go @@ -105,7 +105,7 @@ func NewWriter(out console.File) (Writer, error) { events: map[string]Event{}, repeated: false, done: make(chan bool), - mtx: &sync.RWMutex{}, + mtx: &sync.Mutex{}, }, nil }