Skip to content

Commit

Permalink
Fix concurrency issue
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiught committed Apr 20, 2023
1 parent 5200afd commit 33562f5
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions internal/cli/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func tailLogsCmd(cli *cli) *cobra.Command {
set := make(map[string]struct{})
list = dedupeLogs(list, set)

go func() {
go func(lastLogID string) {
defer close(logsCh)

for {
Expand All @@ -139,7 +139,7 @@ func tailLogsCmd(cli *cli) *cobra.Command {
queryParams = append(queryParams, management.Query(inputs.Filter))
}

list, err = cli.api.Log.List(queryParams...)
list, err := cli.api.Log.List(queryParams...)
if err != nil {
cli.renderer.Errorf("Failed to get latest logs: %v", err)
return
Expand All @@ -150,12 +150,12 @@ func tailLogsCmd(cli *cli) *cobra.Command {
lastLogID = list[len(list)-1].GetLogID()
}

if len(list) < 90 {
if len(list) < logsPerPageLimit {
// Not a lot is happening, sleep on it.
time.Sleep(1 * time.Second)
time.Sleep(time.Second)
}
}
}()
}(lastLogID)

cli.renderer.LogTail(list, logsCh, !cli.debug)
return nil
Expand Down

0 comments on commit 33562f5

Please sign in to comment.