From b017e9f06c0c11b261b88bef8310547f36fc8119 Mon Sep 17 00:00:00 2001 From: Marcin Wyszynski Date: Mon, 2 May 2022 13:42:42 +0200 Subject: [PATCH] Fix spacectl race on terminal state when reading logs (#58) --- internal/cmd/stack/run_logs.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/internal/cmd/stack/run_logs.go b/internal/cmd/stack/run_logs.go index 25c0faa..0eb8246 100644 --- a/internal/cmd/stack/run_logs.go +++ b/internal/cmd/stack/run_logs.go @@ -17,6 +17,7 @@ func runLogs(ctx context.Context, stack, run string) (terminal *structs.RunState go func() { terminal, err = runStates(ctx, stack, run, lines) + close(lines) }() for line := range lines { @@ -27,8 +28,6 @@ func runLogs(ctx context.Context, stack, run string) (terminal *structs.RunState } func runStates(ctx context.Context, stack, run string, sink chan<- string) (*structs.RunStateTransition, error) { - defer func() { close(sink) }() - var query struct { Stack *struct { Run *struct {