From 6be205fd40a1530c4839dbeae7ac97776ca36d16 Mon Sep 17 00:00:00 2001 From: kuangzhiqiang Date: Sun, 3 Feb 2019 19:12:13 +0800 Subject: [PATCH] client close: rpc: unable to write error response when client close notice: "rpc: unable to write error response..." --- server/rpc_server.go | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) 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