diff --git a/src/server.rs b/src/server.rs index 4cb5cf2..387d41d 100644 --- a/src/server.rs +++ b/src/server.rs @@ -329,7 +329,7 @@ where { pub(crate) fn new(recv: C::RecvStream) -> (Self, UnwrapToPending>) { let (error_send, error_recv) = oneshot::channel(); - let error_recv = UnwrapToPending(error_recv); + let error_recv = UnwrapToPending(futures_lite::future::fuse(error_recv)); (Self(recv, Some(error_send), PhantomData), error_recv) } } @@ -449,12 +449,13 @@ impl fmt::Display for RpcServerError { impl error::Error for RpcServerError {} /// Take an oneshot receiver and just return Pending the underlying future returns `Err(oneshot::Canceled)` -pub(crate) struct UnwrapToPending(oneshot::Receiver); +pub(crate) struct UnwrapToPending(futures_lite::future::Fuse>); impl Future for UnwrapToPending { type Output = T; fn poll(mut self: Pin<&mut Self>, cx: &mut task::Context<'_>) -> Poll { + // todo: use is_terminated from tokio 1.44 here to avoid the fused wrapper match Pin::new(&mut self.0).poll(cx) { Poll::Ready(Ok(x)) => Poll::Ready(x), Poll::Ready(Err(_)) => Poll::Pending,