You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I believe I found an race condition with blocking resources. When loading a blocking resource in a <Suspense/>, I'm sometimes getting:
thread 'tokio-runtime-worker' panicked at reactive_graph-0.1.0-beta5/src/computed/async_derived/future_impls.rs:83:29:
At reproduce-leptos-0-7-beta5/src/app.rs:70:33, you tried to access a reactive value which was defined at src/app.rs:61:20, but it has already been disposed.
From my short tests, it looks like this is more likely to happen when the resource takes some time to load (hence the sleep in the reproduction below).
Leptos Dependencies
leptos = { version = "0.7.0-beta5", features = ["nightly"] }
leptos_axum = { version = "0.7.0-beta5", optional = true }
leptos_meta = { version = "0.7.0-beta5" }
leptos_router = { version = "0.7.0-beta5", features = ["nightly"] }
To Reproduce
use leptos::either::Either;
use leptos::prelude::*;
use leptos_meta::{provide_meta_context, MetaTags, Stylesheet, Title};
use leptos_router::{
components::{Route, Router, Routes},
StaticSegment,
};
pub fn shell(options: LeptosOptions) -> impl IntoView {
view! {
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<AutoReload options=options.clone() />
<HydrationScripts options/>
<MetaTags/>
</head>
<body>
<App/>
</body>
</html>
}
}
#[server]
pub async fn data() -> Result<String, ServerFnError> {
tokio::time::sleep(tokio::time::Duration::from_millis(1000)).await;
log!("Get data.");
Ok(String::from("hello world"))
}
#[component]
pub fn App() -> impl IntoView {
// Provides context that manages stylesheets, titles, meta tags, etc.
provide_meta_context();
view! {
// injects a stylesheet into the document <head>
// id=leptos means cargo-leptos will hot-reload this stylesheet
<Stylesheet id="leptos" href="/pkg/reproduce-leptos-0-7-beta5.css"/>
// sets the document title
<Title text="Welcome to Leptos"/>
// content for this welcome page
<Router>
<main>
<Routes fallback=|| "Page not found.".into_view()>
<Route path=StaticSegment("") view=HomePage/>
</Routes>
</main>
</Router>
}
}
/// Renders the home page of your application.
#[component]
fn HomePage() -> impl IntoView {
let resource = Resource::new_blocking(
move || (),
move |_| data()
);
view! {
<h1>"Welcome to Leptos!"</h1>
<Suspense>
{
move || Suspend::new(async move {
match &resource.await {
Ok(value) => Either::Left(view! { <div>{value.clone()}</div> }),
Err(_e) => Either::Right(view! { <div>"Error test"</div> }),
}
})
}
</Suspense>
}
}
As mentioned before, the error doesn't systematically appear, so maybe you'll need to try a few times or play with the tokio::time::sleep to reproduce it. Please tell me if there is any way I can help :)
The text was updated successfully, but these errors were encountered:
Hello,
I believe I found an race condition with blocking resources. When loading a blocking resource in a
<Suspense/>
, I'm sometimes getting:From my short tests, it looks like this is more likely to happen when the resource takes some time to load (hence the sleep in the reproduction below).
Leptos Dependencies
To Reproduce
As mentioned before, the error doesn't systematically appear, so maybe you'll need to try a few times or play with the tokio::time::sleep to reproduce it. Please tell me if there is any way I can help :)
The text was updated successfully, but these errors were encountered: