Comments (4)
I did some digging after so long I find that it is happening because of RwLock
How to get more then one writable session?
from axum-sessions.
i am having some issue with axum-sessions. WritableSession is just loading forever. But same Wrirable session works in my 3 handler function but for weird reason it just does not in one of my handler.
Does not work handler
pub async fn store_admin_user_handler( mut session: WritableSession, app_state: State<Arc<AppState>>, Form(payload): Form<StoreAdminUserRequest>, ) -> Result<impl IntoResponse, impl IntoResponse> { Ok(Json(json!({})).into_response()) }
Below handler it works perfectly fine.
pub async fn post_admin_login_handler( mut session: WritableSession, app_state: State<Arc<AppState>>, Form(payload): Form<LoginAdminUserRequest>, ) -> Result<impl IntoResponse, impl IntoResponse> { Ok(Json(json!({})).into_response()) }
Omg I wish I seen this, I am literally facing same issue and was thinking of dropping the lock myself but if I have to manage the lock myself for more than one writable/readable session then I think it might be design issue?
Currently I have to do something like:
pub async fn auth_middleware_cookie<B>(
State(state): State<AppState>,
request: Request<B>,
next: Next<B>,
) -> Response {
tracing::info!("Auth middleware cookie");
let session_handle = request.extensions().get::<SessionHandle>().unwrap().clone();
tracing::info!("About to read from session handle");
let session = session_handle.read().await;
tracing::info!("Read from session handle completed");
drop(session);
tracing::info!("Calling next middleware");
let response = next.run(request).await;
tracing::info!("Response: {:?}", response);
response
}
If I don't have the drop(session) it just never goes to the handler and hangs there causing it to timeout.
from axum-sessions.
Please see #50.
from axum-sessions.
@maxcountryman thanks for it. I did see that PR. Good works
from axum-sessions.
Related Issues (20)
- Idea: Rework session service implementation to use the new axum 0.6 state pattern HOT 3
- Please consider to keep a changelog HOT 4
- How to retrieve a readable session in middleware? HOT 11
- Resist session id name fingerprinting by default HOT 2
- Rustdoc code doesn't compile due to minor import error HOT 2
- Session not saving when returning a redirect response HOT 7
- "Session handle still has owners" HOT 5
- ReadableSession test utils HOT 1
- How to connect to redis or pg ? HOT 1
- Type-safe `Session` handles HOT 1
- Add a listener trait to listen to the creation, update and destruction of sessions HOT 3
- Implementing `MemoryStore` HOT 5
- Memory session is not persisted (on RPi Arm) HOT 3
- Deadlock when using WritableSession in middleware layer HOT 8
- Bug: data present in session, but `.get` returns `None` HOT 2
- How to make one-shot session?
- Session expiration has no effect
- How to destroy then insert in the same route?
- How to persist postgres sessions between server restarts or load balanced servers? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from axum-sessions.