Skip to content

Commit 791b138

Browse files
committed
Comment in tonic::status::find_status_in_source_chain
Comment mentions why we choose “Unavailable” for connection errors
1 parent 39f9f11 commit 791b138

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

tonic/src/status.rs

+5
Original file line numberDiff line numberDiff line change
@@ -614,6 +614,11 @@ fn find_status_in_source_chain(err: &(dyn Error + 'static)) -> Option<Status> {
614614
return Some(Status::cancelled(timeout.to_string()));
615615
}
616616

617+
// If we are unable to connect to the server, map this to UNAVAILABLE. This is
618+
// consistent with the behavior of a C++ gRPC client when the server is not running, and
619+
// matches the spec of:
620+
// > The service is currently unavailable. This is most likely a transient condition that
621+
// > can be corrected if retried with a backoff.
617622
#[cfg(feature = "transport")]
618623
if let Some(connect) = err.downcast_ref::<crate::transport::ConnectError>() {
619624
return Some(Status::unavailable(connect.to_string()));

0 commit comments

Comments
 (0)