diff --git a/client/rpctimeout.go b/client/rpctimeout.go index 98021e78b4..37ebdd909c 100644 --- a/client/rpctimeout.go +++ b/client/rpctimeout.go @@ -109,7 +109,7 @@ func rpcTimeoutMW(mwCtx context.Context) endpoint.Middleware { e := panicToErr(ctx, panicInfo, ri) done <- e } - if !errors.Is(err, kerrors.ErrRPCFinish) { + if err == nil || !errors.Is(err, kerrors.ErrRPCFinish) { // Don't regards ErrRPCFinish as normal error, it happens in retry scene, // ErrRPCFinish means previous call returns first but is decoding. close(done) diff --git a/pkg/remote/codec/default_codec.go b/pkg/remote/codec/default_codec.go index 3c29ce0a4f..a2f674e88c 100644 --- a/pkg/remote/codec/default_codec.go +++ b/pkg/remote/codec/default_codec.go @@ -247,6 +247,9 @@ func checkRPCState(ctx context.Context, message remote.Message) error { if message.RPCRole() == remote.Server { return nil } + if ctx.Err() == context.DeadlineExceeded || ctx.Err() == context.Canceled { + return kerrors.ErrRPCFinish + } if respOp, ok := ctx.Value(retry.CtxRespOp).(*int32); ok { if !atomic.CompareAndSwapInt32(respOp, retry.OpNo, retry.OpDoing) { // previous call is being handling or done