fix(transport): Return connection error on Channel::connect (#413)
Before this fix, if the connect phase of the transport failed before ever establishing a connection, we would never return the error until the first call to send a request. This PR changes that behavior to only forward the error to the call method if we have ever made a connection before. If we have never established a connection before then `Reconnect` will return an error on the call to `poll_ready`. Fixes #403
This commit is contained in:
@@ -18,6 +18,7 @@ where
|
||||
state: State<M::Future, M::Response>,
|
||||
target: Target,
|
||||
error: Option<M::Error>,
|
||||
has_been_connected: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
@@ -37,6 +38,7 @@ where
|
||||
state: State::Idle,
|
||||
target,
|
||||
error: None,
|
||||
has_been_connected: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -84,14 +86,23 @@ where
|
||||
}
|
||||
Poll::Ready(Err(e)) => {
|
||||
trace!("poll_ready; error");
|
||||
|
||||
state = State::Idle;
|
||||
self.error = Some(e.into());
|
||||
break;
|
||||
|
||||
if self.has_been_connected {
|
||||
self.error = Some(e.into());
|
||||
break;
|
||||
} else {
|
||||
return Poll::Ready(Err(e.into()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
State::Connected(ref mut inner) => {
|
||||
trace!("poll_ready; connected");
|
||||
|
||||
self.has_been_connected = true;
|
||||
|
||||
match inner.poll_ready(cx) {
|
||||
Poll::Ready(Ok(())) => {
|
||||
trace!("poll_ready; ready");
|
||||
|
||||
Reference in New Issue
Block a user