-
-
Notifications
You must be signed in to change notification settings - Fork 56
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
Cannot keep ref to extension objects across .await points in handlers/middlewares #295
Comments
It is because the One possible way to solve this might be to change the Currently the only solution to solve your issue is either to constraint your ref to a limited scope before your
async fn middleware(socket: SocketRef) -> Result<(), socketioxide::SocketError<()>> {
{
let ext: &Extensions = &socket.extensions;
let number: Option<Ref<i32>> = ext.get::<i32>();
}
let _ = test_async().await;
Ok(())
} or to clone the content and discard the |
Thanks for the answer, I just tried to use cloning for now, as the objects where not too complicated. But the solution with the limitation of the scope is good one, did not figure out it myself Are there any plans to add rwlock/mutex to extensions? |
Actually, it is global to every handlers (not only middlewares). |
Describe the bug
Cannot use socket extensions inside async namespace middleware
To Reproduce
Code that reproduce error:
main.rs
Cargo.toml
Error:
Expected behavior
The code is being compiled, extensions are working properly
Versions (please complete the following information):
Additional context
-
The text was updated successfully, but these errors were encountered: