Skip to content

Commit

Permalink
fix: close loki stream correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
motoki317 committed May 6, 2023
1 parent 3f5c65c commit b4d2634
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pkg/infrastructure/log/loki/streamer.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,13 @@ func (l *lokiStreamer) Stream(ctx context.Context, appID string, after time.Time
ch := make(chan *domain.ContainerLog, 100)

go func() {
defer conn.Close()
<-ctx.Done()
_ = conn.Close()
defer close(ch)
}()
go func() {
defer log.Infof("closing loki websocket stream")
log.Infof("new loki websocket stream")

for {
typ, b, err := conn.ReadMessage()
Expand Down

0 comments on commit b4d2634

Please sign in to comment.