diff --git a/rpc/dataconn/dataconn_server.go b/rpc/dataconn/dataconn_server.go index 646545f..ea6700b 100644 --- a/rpc/dataconn/dataconn_server.go +++ b/rpc/dataconn/dataconn_server.go @@ -146,12 +146,17 @@ func (s *Server) serveConn(nc *transport.AuthConn) { // if marshaling fails. We consider failed marshaling a handler error var protobuf *bytes.Buffer if handlerErr == nil { - protobufBytes, err := proto.Marshal(res) - if err != nil { - s.log.WithError(err).Error("cannot marshal handler protobuf") - handlerErr = err + if res == nil { + handlerErr = fmt.Errorf("implementation error: handler for endpoint %q returns nil error and nil result", endpoint) + s.log.WithError(err).Error("handle implementation error") + } else { + protobufBytes, err := proto.Marshal(res) + if err != nil { + s.log.WithError(err).Error("cannot marshal handler protobuf") + handlerErr = err + } + protobuf = bytes.NewBuffer(protobufBytes) // SHADOWING } - protobuf = bytes.NewBuffer(protobufBytes) // SHADOWING } var resHeaderBuf bytes.Buffer