From 1b0822e5a150e128365250ea25232c83e751c9ae Mon Sep 17 00:00:00 2001 From: Kent Iso Date: Fri, 28 Jun 2024 20:35:38 +0900 Subject: [PATCH] Fix go routine leak --- frontend/frontend.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/frontend/frontend.go b/frontend/frontend.go index 2870e4ed..e600aa1b 100644 --- a/frontend/frontend.go +++ b/frontend/frontend.go @@ -119,14 +119,19 @@ func streamAssignments(ctx context.Context, assignments chan *pb.Assignment, err errs <- fmt.Errorf("error getting assignment stream: %w", err) return } - for { + + var assignment *pb.Assignment + for assignment.GetConnection() == "" { resp, err := stream.Recv() if err != nil { errs <- fmt.Errorf("error streaming assignment: %w", err) return } - assignments <- resp.Assignment + assignment = resp.Assignment } + + assignments <- assignment + log.Printf("Got assignment: %v", assignment) } func connectFrontendServer() (*grpc.ClientConn, error) {