Skip to content

Commit f68d3ad

Browse files
committed
fix grpc: use no-OK grpc status when CompletionQueue returned ok=false on the client-side Finish
commit_hash:42188f3ad14baf8c26e2c292a60bf0a7506e3acd
1 parent fb19ca5 commit f68d3ad

1 file changed

Lines changed: 15 additions & 3 deletions

File tree

grpc/include/userver/ugrpc/client/impl/unary_call.hpp

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,21 @@ class UnaryCall final {
181181
return std::move(status_);
182182

183183
case ugrpc::impl::AsyncMethodInvocation::WaitStatus::kError:
184-
// CompletionQueue returned ok=false.
185-
// RPC has finished in abnormal manner.
186-
// This could mean the response message was not received or could not be deserialized.
184+
// CompletionQueue returned ok=false on the client-side Finish. grpcpp still fills
185+
// `status_` from the received trailers (a real server status), or from a status that
186+
// grpc-core synthesized when the call failed/was cancelled (e.g. UNAVAILABLE or
187+
// CANCELLED, see grpc/grpc#4972). Do not discard that grpc-core status: surface it so
188+
// it is mapped to the proper exception and retried like any other gRPC status.
189+
if (impl::IsRequestCancelledByDeadlinePropagation(status_, state_)) {
190+
return utils::unexpected{SpecialCaseCompletionType::kTimeoutDeadlinePropagated};
191+
}
192+
if (!status_.ok()) {
193+
ugrpc::impl::ClampStatusCodeToValidRange(status_);
194+
return std::move(status_);
195+
}
196+
// ok==false while the trailing status is OK means the response was not received or
197+
// could not be deserialized: there is no valid response and no meaningful status to
198+
// surface, so report a (retryable) network error.
187199
return utils::unexpected{SpecialCaseCompletionType::kNetworkError};
188200

189201
case ugrpc::impl::AsyncMethodInvocation::WaitStatus::kCancelled:

0 commit comments

Comments
 (0)