tonic icon indicating copy to clipboard operation
tonic copied to clipboard

Duplex transport is incompatible with `serve_with_incoming_shutdown`

Open shradej1 opened this issue 1 year ago • 0 comments

Bug Report

Version

11.0 / HEAD

Platform

Darwin (macOS Sonoma 14.2.1) kernel version 23.2.0

Description

In trying to integration test a tonic client/server, I found the "examples/src/mock" example using tokio::io::duplex as the transport channel. This worked fine, until I changed serve_with_incoming to serve_with_incoming_shutdown.

Replacing

tokio::spawn(async move {
        Server::builder()
            .add_service(GreeterServer::new(greeter))
            .serve_with_incoming(tokio_stream::once(Ok::<_, std::io::Error>(server)))
            .await
    });

with

tokio::spawn(async move {
        Server::builder()
            .add_service(GreeterServer::new(greeter))
            .serve_with_incoming_shutdown(
                tokio_stream::once(Ok::<_, std::io::Error>(server)),
                async move { std::future::pending().await },
            )
            .await
    });

in examples/src/mock/mock.rs demonstrates that the example no longer runs successfully, instead erroring with a "Client already taken" error. This was unexpected to me.

shradej1 avatar Mar 05 '24 22:03 shradej1