-
Notifications
You must be signed in to change notification settings - Fork 88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
version incompatibility with async libraries #79
Comments
Things these days are better, as the ecosystem has been steadily moving toward tokio 1.0. In order to reproduce this type of situation, I had to "cheat" a little bit, by deliberately using a version of a library that is a few months old (so that it would depend on an older version of tokio). But I'm certain a variant of this problem would have been possible to stumble upon in the wild sometime in late 2019. This project uses the latest tokio (1.0) and tokio-tungstenite version 0.12, which requires tokio 0.3. This version of tokio-tungstenite was released November 2020. [dependencies]
tokio-tungstenite = "0.12.0"
tokio = { version = "1", features = ["rt", "full"] } The code looks like this: #[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let _ = tokio_tungstenite::connect_async("ws://localhost:8080").await;
Ok(())
} Cargo can resolve the package dependency tree without errors, and the code compiles without errors. But at runtime:
This error especially fun because if we look at our Cargo.toml, we can see that explicitly enabled the "rt" feature flag on tokio (or at least it appears that way) |
@eminence an example without "cheating" would be actix web right now. It has no version with support to Tokio 1.0 today. If you try to use it with the latest version of reqwest or sqlx, you're gonna get in trouble. |
@eduardocanellas great point, thanks! #[actix_web::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let body = reqwest::get("https://www.rust-lang.org")
.await?
.text()
.await?;
Ok(())
} The above code gives us our favorite panic:
|
This is covered decently well in https://rust-lang.github.io/wg-async-foundations/vision/status_quo/alan_picks_web_server.html -- closing |
@nikomatsakis that link points to a 404 page |
Brief summary:
I feel a lot like Alan. An annoying situation which is happening to me in async Rust is having to handle dependencies which needs different versions of the same runtime (tokio's transition to 1.0). I feel like "doing cargo's work" when I have to find the right combination of features and versions on my dependencies just to be able to run my code without panics.
Originally posted by @eduardocanellas in #70 (comment)
Optional details
The text was updated successfully, but these errors were encountered: