diff --git a/server/rpc_server.go b/server/rpc_server.go index de3b8fd3..7faf26d4 100644 --- a/server/rpc_server.go +++ b/server/rpc_server.go @@ -157,15 +157,17 @@ func (s *rpcServer) ServeConn(sock transport.Socket) { // TODO: handle error better if err := handler(ctx, request, response); err != nil { - // write an error response - err = rcodec.Write(&codec.Message{ - Header: msg.Header, - Error: err.Error(), - Type: codec.Error, - }, nil) - // could not write the error response - if err != nil { - log.Logf("rpc: unable to write error response: %v", err) + if err != lastStreamResponseError { + // write an error response + err = rcodec.Write(&codec.Message{ + Header: msg.Header, + Error: err.Error(), + Type: codec.Error, + }, nil) + // could not write the error response + if err != nil { + log.Logf("rpc: unable to write error response: %v", err) + } } s.wg.Done() return