Skip to content
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

WIP: upgrade to axum 0.8 #2705

Draft
wants to merge 10 commits into
base: master
Choose a base branch
from
Draft

WIP: upgrade to axum 0.8 #2705

wants to merge 10 commits into from

Conversation

syphar
Copy link
Member

@syphar syphar commented Jan 2, 2025

I believe there is an open bug with axum blocking this upgrade: tokio-rs/axum#3138 there is a workaround for this bug, which I already added (using .nest_service instead of .nest)

@github-actions github-actions bot added the S-waiting-on-review Status: This pull request has been implemented and needs to be reviewed label Jan 2, 2025
@@ -154,6 +154,7 @@ about_page!(AboutPageMetadata, "core/about/metadata.html");
about_page!(AboutPageRedirection, "core/about/redirections.html");
about_page!(AboutPageDownload, "core/about/download.html");

#[axum::debug_handler]
pub(crate) async fn about_handler(subpage: Option<Path<String>>) -> AxumResult<impl IntoResponse> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

out of curiosity: wouldn't it be more straight-forward to have the subpages be part of the router and have dedicated handlers for them? :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably :)

this is historically coming the old iron routes, and I didn't change how they were structured when migrating to axum.

( the list of possible refactors is very long 😄 , I'm trying to make progress as much as possible )

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see :)

@syphar syphar self-assigned this Jan 2, 2025
src/web/mod.rs Outdated
@@ -413,7 +413,9 @@ async fn apply_middleware(
Ok(router.layer(
ServiceBuilder::new()
.layer(TraceLayer::new_for_http())
.layer(sentry_tower::NewSentryLayer::new_from_top())
// FIXME: send / sync error?
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure why this breaks, my guess is that sentry-tower is the problem, because its SentryLayer contains _hub: PhantomData<(H, Request)>, where the axum request is not Sync.

I might be wrong, but will have to do more digging on this. If I'm right then Crates.io will likely also run into this same issue, will also see how they fix it

Copy link
Member Author

@syphar syphar Jan 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting. We're using the MatchedPath sentry extension for axum which is still using the old version, which is why I hadn't updated yet. I was assuming that that would be all that needs updating 😅

Copy link
Member Author

@syphar syphar Jan 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't realize sentry-tower implemented this :)

( I built a small middleware for the same thing)

Interesting. We're using the MatchedPath sentry extension for axum which is still using the old version, which is why I hadn't updated yet. I was assuming that that would be all that needs updating 😅

My guess is that it will break the same way :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It did after I implemented it a while ago :D

.nest("/-/static/", build_static_router())
// `.nest` with fallbacks is currently broken, `.nest_service works
// https://github.com/tokio-rs/axum/issues/3138
.nest_service("/-/static", build_static_router())
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Turbo87 also you might run into this one when working on crates.io :)

( not sure how you are using nesting?)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we're not using nesting and provide static assets via middleware, but we'll see...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: This pull request has been implemented and needs to be reviewed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants