Closed
Description
Environment
- sentry 0.35.0
- axum 0.8.1
Steps to Reproduce
When upgrading docs.rs itself to axum 0.8 I stumbled onto this issue.
use axum::{routing::get, Router};
#[tokio::main]
async fn main() {
let app = Router::new()
.route("/", get(|| async { "Hello, World!" }))
.layer(sentry_tower::NewSentryLayer::new_from_top()); // this fails because the service is not `Sync`
let listener = tokio::net::TcpListener::bind("0.0.0.0:3000").await.unwrap();
axum::serve(listener, app).await.unwrap();
}
With axum 0.8 all Layers & services are expected to be Sync
(tokio-rs/axum#2473).
sentry_tower::SentryLayer
and ::SentryService
are only Sync
if the given Request
is Sync
, which the default axum::request::Request
isn't.
So my guess is that every axum user will run into this issue.
Expected Result
Since the Request
is only used in a function argument in the HubProvider
, I assume that the service / layer could totally be Sync
.
Actual Result
error[E0277]: `(dyn HttpBody<Data = axum::body::Bytes, Error = axum::Error> + Send + 'static)` cannot be shared between threads safely
--> src/main.rs:8:16
|
8 | .layer(sentry_tower::NewSentryLayer::new_from_top());
| ----- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `(dyn HttpBody<Data = axum::body::Bytes, Error = axum::Error> + Send + 'static)` cannot be shared between thre
ads safely
| |
| required by a bound introduced by this call
|
potential solution?
From what I see, the solution could be something like this. It definitely compiles in docs.rs. I'm not sure about what tests would be expected.
Metadata
Metadata
Assignees
Labels
No labels