Skip to content

Commit

Permalink
fix: Watch log hangs when we're in a terminal state (#251)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasmik authored Aug 29, 2024
1 parent 4c916ad commit 637a82d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions internal/cmd/stack/run_logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func runStates(ctx context.Context, stack, run string, sink chan<- string, acFn
fmt.Println("")

if transition.HasLogs {
if err := runStateLogs(ctx, stack, run, transition.State, transition.StateVersion, sink); err != nil {
if err := runStateLogs(ctx, stack, run, transition.State, transition.StateVersion, sink, transition.Terminal); err != nil {
return nil, err
}
}
Expand All @@ -152,7 +152,7 @@ func runStates(ctx context.Context, stack, run string, sink chan<- string, acFn
}
}

func runStateLogs(ctx context.Context, stack, run string, state structs.RunState, version int, sink chan<- string) error {
func runStateLogs(ctx context.Context, stack, run string, state structs.RunState, version int, sink chan<- string, stateTerminal bool) error {
var query struct {
Stack *struct {
Run *struct {
Expand Down Expand Up @@ -204,7 +204,7 @@ func runStateLogs(ctx context.Context, stack, run string, state structs.RunState
sink <- message.Body
}

if logs.Finished {
if logs.Finished || (!logs.HasMore && stateTerminal) {
break
}

Expand Down

0 comments on commit 637a82d

Please sign in to comment.