Skip to content

Commit

Permalink
Gracefully handle situation when container details have not yet loaded
Browse files Browse the repository at this point in the history
This should be very rare but it does happen sometimes
  • Loading branch information
jesseduffield committed May 26, 2024
1 parent 623fdb4 commit 8a0fcf9
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion pkg/gui/container_logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,24 @@ func (gui *Gui) writeContainerLogs(container *commands.Container, ctx context.Co
}
defer readCloser.Close()

if container.DetailsLoaded() && container.Details.Config.Tty {
if !container.DetailsLoaded() {
// loop until the details load or context is cancelled, using timer
ticker := time.NewTicker(time.Millisecond * 100)
defer ticker.Stop()
outer:
for {
select {
case <-ctx.Done():
return nil
case <-ticker.C:
if container.DetailsLoaded() {
break outer
}
}
}
}

if container.Details.Config.Tty {
_, err = io.Copy(writer, readCloser)
if err != nil {
return err
Expand Down

0 comments on commit 8a0fcf9

Please sign in to comment.