Skip to content

Commit

Permalink
ensure stream write timeout gets cancelled
Browse files Browse the repository at this point in the history
  • Loading branch information
NyaaaWhatsUpDoc committed Feb 12, 2024
1 parent 46ef2e5 commit 99df0d5
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion internal/api/client/streaming/stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -354,11 +354,14 @@ func (m *Module) writeToWSConn(

for {
// Wrap stream context with timeout to send a ping.
ctx, _ := context.WithTimeout(stream.Context(), ping)
ctx, cncl := context.WithTimeout(stream.Context(), ping)

// Block on receipt of next message.
msg, ok, open := stream.Recv(ctx)

// Stop timer.
cncl()

if !open {
// Stream was
// closed.
Expand Down

0 comments on commit 99df0d5

Please sign in to comment.