Skip to content

Commit

Permalink
fix: close stopped channel
Browse files Browse the repository at this point in the history
  • Loading branch information
haoqixu committed Mar 7, 2024
1 parent 574baa6 commit d5c6e3a
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions client/internal/wsreceiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,16 @@ func (r *wsReceiver) ReceiverLoop(ctx context.Context) {
err error
}

defer func() { close(r.stopped) }()

for {
select {
case <-ctx.Done():
return
default:
result := make(chan receivedMessage, 1)

// To stop this goroutine, close the websocket connection
go func() {
var message protobufs.ServerToAgent
err := r.receiveMessage(&message)
Expand Down

0 comments on commit d5c6e3a

Please sign in to comment.