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:
Lucio Franco
2020-07-27 12:44:11 -04:00
committed by GitHub
parent 5bd8a04baf
commit 2ea17b2ecf
2 changed files with 68 additions and 2 deletions
+13 -2
View File
@@ -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");