seanmonstar / reqwest

An easy and powerful Rust HTTP Client
https://docs.rs/reqwest
Apache License 2.0
9.43k stars 1.05k forks source link

`Cargo.toml` downloaded from cartes.io does not have the required feature `runtime-tokio` set for `quinn` #1877

Closed ouromoros closed 1 month ago

ouromoros commented 1 year ago

So I'm trying to make http3 feature for reqwest package work. After some struglling with the RUSTFLAG configuration, I finally made the project compile with reqwest = { version = "0.11.18", features = ["http3"] }

Now the problem is when I try to initiate a client, it throws error: unable to create QUIC endpoint: Custom { kind: Other, error: "no async runtime found" }.

After some digging, the error happens in this code block in quinn package:

pub fn default_runtime() -> Option<Arc<dyn Runtime>> {
    #[cfg(feature = "runtime-tokio")]
    {
        if ::tokio::runtime::Handle::try_current().is_ok() {
            return Some(Arc::new(TokioRuntime));
        }
    }

    #[cfg(feature = "runtime-async-std")]
    {
        return Some(Arc::new(AsyncStdRuntime));
    }

    #[cfg(not(feature = "runtime-async-std"))]
    None
}

I double checked that ::tokio::runtime::Handle::try_current() does return an OK result. I then checked the Cargo.toml stored in local reqwest package, it seemed that quinn is missing the runtime-tokio feature that is supposed to be there:

[target."cfg(not(target_arch = \"wasm32\"))".dependencies.quinn]
version = "0.10"
features = [
    "tls-rustls",
    "ring",
]
optional = true
default-features = false

Honestly I have no clue what's going on here. In Github repo runtime-tokio is clearly set for quinn, yet the Cargo.toml from the downloaded package just does not have it. It could be that I'm doing something wrong here, but I really don't know it.

Also I'm on stable-x86_64-pc-windows-msvc (default) rustc 1.70.0 (90c541806 2023-05-31), not sure if that matters.

seanmonstar commented 1 year ago

A new version with the fix hasn't yet been published to crates.io. I'll publish one shortly.

You can fix your program sooner by depending on Quinn yourself, and enabling the feature.

ouromoros commented 1 year ago

@seanmonstar Thanks for the fast response! Just out of my curiosity, how did the problem occur?