File tree Expand file tree Collapse file tree
grpc/include/userver/ugrpc/client/impl Expand file tree Collapse file tree Original file line number Diff line number Diff 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 :
You can’t perform that action at this time.
0 commit comments