Skip to content

Client panic #2555

@gammelalf

Description

@gammelalf

Bug Report

Hi, I experimented with writing a tonic client "by hand" i.e. without codegen in a build script.
Sadly my most basic test panics.

Am I missing something or is it a bug?

versions

├── tonic v0.14.5
└── tonic-prost v0.14.5
    └── tonic v0.14.5 (*)

Platform

Linux redacted 6.18.13-arch1-1 #1 SMP PREEMPT_DYNAMIC Wed, 25 Feb 2026 23:12:35 +0000 x86_64 GNU/Linux

Description

I ran the following and it panics without reaching the server.

src/main.rs

use tonic::Request;
use tonic::client::Grpc;
use tonic::codegen::http::uri::PathAndQuery;
use tonic::transport::Channel;
use tonic::transport::Uri;
use tonic_prost::ProstCodec;

#[derive(prost::Message)]
struct Foo {}

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    let channel = Channel::builder(Uri::from_static("http://127.0.0.1:8080"))
        .connect()
        .await?;

    Grpc::new(channel)
        .unary(
            Request::new(Foo {}),
            PathAndQuery::from_static("/foo/bar"),
            ProstCodec::<Foo, Foo>::new(),
        )
        .await?;

    Ok(())
}

Cargo.toml

[package]
name = "client"
version = "0.1.0"
edition = "2024"
publish = false

[dependencies]
tonic = { version = "~0.14", features = ["transport", "channel"] }
anyhow = { version = "~1" }
tokio = { version = "~1", features = ["full"] }
prost = { version = "~0.14", features = ["derive"] }
tonic-prost = { version = "~0.14" }

Output

thread 'main' (236722) panicked at /home/gammelalf/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tower-0.5.3/src/buffer/service.rs:122:23:
`send_item` called without first calling `poll_reserve`
stack backtrace:
   0: __rustc::rust_begin_unwind
             at /rustc/254b59607d4417e9dffbc307138ae5c86280fe4c/library/std/src/panicking.rs:689:5
   1: core::panicking::panic_fmt
             at /rustc/254b59607d4417e9dffbc307138ae5c86280fe4c/library/core/src/panicking.rs:80:14
   2: tokio_util::sync::mpsc::PollSender<T>::send_item
             at /home/gammelalf/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-util-0.7.18/src/sync/mpsc.rs:186:17
   3: <tower::buffer::service::Buffer<Req,F> as tower_service::Service<Req>>::call
             at /home/gammelalf/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tower-0.5.3/src/buffer/service.rs:122:23
   4: <tonic::transport::channel::Channel as tower_service::Service<http::request::Request<tonic::body::Body>>>::call
             at /home/gammelalf/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tonic-0.14.5/src/transport/channel/mod.rs:218:21
   5: <T as tonic::client::service::GrpcService<ReqBody>>::call
             at /home/gammelalf/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tonic-0.14.5/src/client/service.rs:48:9
   6: tonic::client::grpc::Grpc<T>::streaming::{{closure}}
             at /home/gammelalf/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tonic-0.14.5/src/client/grpc.rs:312:14
   7: tonic::client::grpc::Grpc<T>::client_streaming::{{closure}}
             at /home/gammelalf/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tonic-0.14.5/src/client/grpc.rs:242:50
   8: tonic::client::grpc::Grpc<T>::unary::{{closure}}
             at /home/gammelalf/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tonic-0.14.5/src/client/grpc.rs:222:53
   9: client::main::{{closure}}
             at ./example/client/src/main.rs:23:10
  10: <core::pin::Pin<P> as core::future::future::Future>::poll
             at /home/gammelalf/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/future/future.rs:133:9
  11: tokio::runtime::park::CachedParkThread::block_on::{{closure}}
             at /home/gammelalf/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.50.0/src/runtime/park.rs:284:71
  12: tokio::task::coop::with_budget
             at /home/gammelalf/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.50.0/src/task/coop/mod.rs:167:5
  13: tokio::task::coop::budget
             at /home/gammelalf/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.50.0/src/task/coop/mod.rs:133:5
  14: tokio::runtime::park::CachedParkThread::block_on
             at /home/gammelalf/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.50.0/src/runtime/park.rs:284:31
  15: tokio::runtime::context::blocking::BlockingRegionGuard::block_on
             at /home/gammelalf/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.50.0/src/runtime/context/blocking.rs:66:14
  16: tokio::runtime::scheduler::multi_thread::MultiThread::block_on::{{closure}}
             at /home/gammelalf/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.50.0/src/runtime/scheduler/multi_thread/mod.rs:89:22
  17: tokio::runtime::context::runtime::enter_runtime
             at /home/gammelalf/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.50.0/src/runtime/context/runtime.rs:65:16
  18: tokio::runtime::scheduler::multi_thread::MultiThread::block_on
             at /home/gammelalf/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.50.0/src/runtime/scheduler/multi_thread/mod.rs:88:9
  19: tokio::runtime::runtime::Runtime::block_on_inner
             at /home/gammelalf/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.50.0/src/runtime/runtime.rs:373:50
  20: tokio::runtime::runtime::Runtime::block_on
             at /home/gammelalf/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.50.0/src/runtime/runtime.rs:343:18
  21: client::main
             at ./example/client/src/main.rs:25:7
  22: core::ops::function::FnOnce::call_once
             at /home/gammelalf/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:250:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Process finished with exit code 101

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions