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

"Session handle still has owners" #32

Open
j0lol opened this issue Feb 26, 2023 · 5 comments
Open

"Session handle still has owners" #32

j0lol opened this issue Feb 26, 2023 · 5 comments

Comments

@j0lol
Copy link

j0lol commented Feb 26, 2023

I was trying to use axum-sessions within the leptos framework and I encountered an error where leptos seemed like it would not drop AuthContext. I reported it to leptos and it seems like it is an issue with your middleware:

let session = RwLock::into_inner(
Arc::try_unwrap(session_handle).expect("Session handle still has owners."),
);

Why does this type implement Clone and then panic if it is cloned and used? Why is this not documented? Surely this edge case can be worked around, or at least pushed to a compile-time error?

If you would like to see the issue, this project errors with this reproducibly here

@maxcountryman
Copy link
Owner

The issue is with how the async-session crate implements Clone.

@maxcountryman
Copy link
Owner

It looks like v4 of async-session will allow us to clone the Session directly. This should mean we can drop the lock altogether. As soon as that lands, I'm planning to remove the custom extractor and lock.

@maxcountryman
Copy link
Owner

@j0lol there's active work in #50 to address.

@maxcountryman
Copy link
Owner

I'm also working on a new direction which addresses this among other things. Please see #56.

@maxcountryman
Copy link
Owner

maxcountryman commented Sep 24, 2023

I've released v0.1.0 of tower-sessions for folks who would like to try that.

This new crate does not use async-session and takes an approach to managing inner state that's inline with other tower middleware, like tower-cookies.

If you end up trying it, please let me know how it goes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants