Skip to content

Commit

Permalink
Fixed goroutine leak in subscriptions (#626)
Browse files Browse the repository at this point in the history
  • Loading branch information
korotin authored Nov 28, 2023
1 parent 12e9b90 commit a226fe8
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions subscriptions.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,14 @@ func (s *Schema) subscribe(ctx context.Context, queryString string, operationNam
responses := r.Subscribe(ctx, res, op)
c := make(chan interface{})
go func() {
Loop:
for resp := range responses {
c <- &Response{
Data: resp.Data,
Errors: resp.Errors,
select {
case c <- &Response{Data: resp.Data, Errors: resp.Errors}:
continue

case <-ctx.Done():
break Loop
}
}
close(c)
Expand Down

0 comments on commit a226fe8

Please sign in to comment.