Skip to content

Commit 5c4da09

Browse files
authored
grpc: fix a bug introduced in #7461 (#7505)
1 parent 1008562 commit 5c4da09

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

stream.go

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1121,13 +1121,12 @@ func (a *csAttempt) recvMsg(m any, payInfo *payloadInfo) (err error) {
11211121
}
11221122
// Special handling for non-server-stream rpcs.
11231123
// This recv expects EOF or errors, so we don't collect inPayload.
1124-
if err := recv(a.p, cs.codec, a.s, a.dc, m, *cs.callInfo.maxReceiveMessageSize, nil, a.decomp, false); err == nil {
1125-
return toRPCErr(errors.New("grpc: client streaming protocol violation: get <nil>, want <EOF>"))
1126-
}
1127-
if err == io.EOF {
1124+
if err := recv(a.p, cs.codec, a.s, a.dc, m, *cs.callInfo.maxReceiveMessageSize, nil, a.decomp, false); err == io.EOF {
11281125
return a.s.Status().Err() // non-server streaming Recv returns nil on success
1126+
} else if err != nil {
1127+
return toRPCErr(err)
11291128
}
1130-
return toRPCErr(err)
1129+
return toRPCErr(errors.New("grpc: client streaming protocol violation: get <nil>, want <EOF>"))
11311130
}
11321131

11331132
func (a *csAttempt) finish(err error) {
@@ -1441,13 +1440,12 @@ func (as *addrConnStream) RecvMsg(m any) (err error) {
14411440

14421441
// Special handling for non-server-stream rpcs.
14431442
// This recv expects EOF or errors, so we don't collect inPayload.
1444-
if err := recv(as.p, as.codec, as.s, as.dc, m, *as.callInfo.maxReceiveMessageSize, nil, as.decomp, false); err == nil {
1445-
return toRPCErr(errors.New("grpc: client streaming protocol violation: get <nil>, want <EOF>"))
1446-
}
1447-
if err == io.EOF {
1443+
if err := recv(as.p, as.codec, as.s, as.dc, m, *as.callInfo.maxReceiveMessageSize, nil, as.decomp, false); err == io.EOF {
14481444
return as.s.Status().Err() // non-server streaming Recv returns nil on success
1445+
} else if err != nil {
1446+
return toRPCErr(err)
14491447
}
1450-
return toRPCErr(err)
1448+
return toRPCErr(errors.New("grpc: client streaming protocol violation: get <nil>, want <EOF>"))
14511449
}
14521450

14531451
func (as *addrConnStream) finish(err error) {

0 commit comments

Comments
 (0)