1
0
mirror of https://github.com/go-micro/go-micro.git synced 2025-06-12 22:07:47 +02:00

fix broken pipe error

This commit is contained in:
Asim Aslam
2019-06-03 15:55:47 +01:00
parent 850f8bafdf
commit f80f0eb38e
2 changed files with 16 additions and 16 deletions

View File

@ -214,9 +214,7 @@ func (s *service) call(ctx context.Context, router *router, sending *sync.Mutex,
// declare a local error to see if we errored out already
// keep track of the type, to make sure we return
// the same one consistently
var lastError error
stream := &rpcStream{
rawStream := &rpcStream{
context: ctx,
codec: cc.(codec.Codec),
request: r,
@ -229,9 +227,8 @@ func (s *service) call(ctx context.Context, router *router, sending *sync.Mutex,
if err := returnValues[0].Interface(); err != nil {
// the function returned an error, we use that
return err.(error)
} else if lastError != nil {
// we had an error inside sendReply, we use that
return lastError
} else if serr := rawStream.Error(); serr == io.EOF || serr == io.ErrUnexpectedEOF {
return nil
} else {
// no error, we send the special EOS error
return lastStreamResponseError
@ -242,14 +239,7 @@ func (s *service) call(ctx context.Context, router *router, sending *sync.Mutex,
r.stream = true
// execute handler
if err := fn(ctx, r, stream); err != nil {
return err
}
// this is the last packet, we don't do anything with
// the error here (well sendStreamResponse will log it
// already)
return router.sendResponse(sending, req, nil, cc, true)
return fn(ctx, r, rawStream)
}
func (m *methodType) prepareContext(ctx context.Context) reflect.Value {