diff --git a/validator/rpc/health.go b/validator/rpc/health.go index 6d0e0725bf..b1ef903de3 100644 --- a/validator/rpc/health.go +++ b/validator/rpc/health.go @@ -57,7 +57,12 @@ func (s *Server) GetVersion(ctx context.Context, _ *ptypes.Empty) (*pb.VersionRe // StreamBeaconLogs from the beacon node via a gRPC server-side stream. func (s *Server) StreamBeaconLogs(req *ptypes.Empty, stream pb.Health_StreamBeaconLogsServer) error { - client, err := s.beaconNodeHealthClient.StreamBeaconLogs(s.ctx, req) + // Wrap service context with a cancel in order to propagate the exiting of + // this method properly to the beacon node server. + ctx, cancel := context.WithCancel(s.ctx) + defer cancel() + + client, err := s.beaconNodeHealthClient.StreamBeaconLogs(ctx, req) if err != nil { return err } @@ -67,6 +72,8 @@ func (s *Server) StreamBeaconLogs(req *ptypes.Empty, stream pb.Health_StreamBeac return status.Error(codes.Canceled, "Context canceled") case <-stream.Context().Done(): return status.Error(codes.Canceled, "Context canceled") + case <-client.Context().Done(): + return status.Error(codes.Canceled, "Context canceled") default: resp, err := client.Recv() if err != nil {