Open osmano807 opened 2 weeks ago
Thanks, the repro is great here! Could you do me a favor and test #2911 against your non-minimal example? I think it should fix the issue but not entirely sure.
Don't think so, tested in my project and with the reproduction, still panics.
Leptos Dependencies
leptos = { git = "https://github.com/leptos-rs/leptos.git", features = [
"nightly",
], rev = "refs/pull/2911/head" }
leptos_meta = { git = "https://github.com/leptos-rs/leptos.git", rev = "refs/pull/2911/head" }
leptos_router = { git = "https://github.com/leptos-rs/leptos.git", features = [
"nightly",
], rev = "refs/pull/2911/head" }
leptos_axum = { git = "https://github.com/leptos-rs/leptos.git", rev = "refs/pull/2911/head" }
Panic
thread 'tokio-runtime-worker' panicked at /rustc/0d634185dfddefe09047881175f35c65d68dcff1/library/core/src/ptr/mod.rs:574:1:
Dropped SendWrapper<T> variable from a thread different to the one it has been created with.
Thanks, turns out I was testing it incorrectly.
Here's a simpler reproduction:
#[component]
pub fn App() -> impl IntoView {
view! {
<Router>
<Routes fallback=|| ()>
<ParentRoute path=path!("") view=Parent>
<Route path=path!("") view=Child/>
</ParentRoute>
</Routes>
</Router>
}
}
#[component]
fn Parent() -> impl IntoView {
view! {
<Outlet/>
<Suspense>
<Suspense>
<A href="/new" attr:class="link link-primary">
New Item
</A>
</Suspense>
</Suspense>
}
}
#[component]
pub fn Child() -> impl IntoView {
view! { <Suspense>{move || {}}</Suspense> }
}
The panic is caused by the prop:state
on <A/>
.
Each of three conditions is required for it not to remove the SendWrapper
around the prop correctly:
Suspense
in ChildSuspense
in ParentOutlet
in parentIf any of those three is removed, it does not panic. If <A/>
is not used or <A/>
is modified so that it does not use prop:state
, of course it does not panic.
I'll have to look at it more to figure out what the underlying issue is, though.
This should incidentally be fixed by #2912, which I think is a good idea in any case but which doesn't address the actual problem here.
Describe the bug The application panics with the error message: "Dropped SendWrapper variable from a thread different to the one it has been created with."
When accessing the following code I get a panic in the server. The reproduction is finicky, managed to generate a minimal reproduction copying my project structure. Some changes stops reproducing the panic, like removing the nested
<Suspense>
.Leptos Dependencies
To Reproduce Steps to reproduce the behavior:
start-axum-0.7
template//use leptos::logging::*;
pub fn shell(options: LeptosOptions) -> impl IntoView { view! { <!DOCTYPE html>
}
[component]
pub fn App() -> impl IntoView { provide_meta_context();
}
[component]
fn Hello() -> impl IntoView { view! {
Hello
} }[component]
pub fn ListItems() -> impl IntoView { view! {
}
[component]
fn Header() -> impl IntoView { let user_id = query_user_id();
}
[component]
fn ItemTable() -> impl IntoView { let user_id = query_user_id();
}
pub fn query_user_id() -> Memo<Result<String, String>> { let params = use_params::();
}
[derive(Params, PartialEq, Clone)]
struct UserParams { user_id: String, }
[component]
fn ItemCollectionRoutes() -> impl MatchNestedRoutes + Clone {
view! {
<ParentRoute path=path!("") view=DrawerItemCollection>
<Route path=path!("/a/:user_id/b") view=ListItems />
}
.into_inner()
}
[component]
pub fn DrawerItemCollection() -> impl IntoView { view! { }
}
[component]
fn SidebarItemCollection() -> impl IntoView { let user_id = query_user_id();
}
[component]
fn DrawerGeneric(sidebar: impl IntoView) -> impl IntoView { view! {
}
Expected behavior The application should render the components for the given route without crashing.
Error Message
**Error Log with Backtrace**
``` thread 'tokio-runtime-worker' panicked at /rustc/0d634185dfddefe09047881175f35c65d68dcff1/library/core/src/ptr/mod.rs:574:1: Dropped SendWrapper::try_poll_next at /home/opc/.cargo/registry/src/index.crates.io-6f17d22bba15001f/futures-core-0.3.30/src/stream.rs:196:9 34: as http_body::Body>::poll_frame
at /home/opc/.cargo/registry/src/index.crates.io-6f17d22bba15001f/axum-core-0.4.3/src/body.rs:205:36
35: as http_body::Body>::poll_frame
at /home/opc/.cargo/registry/src/index.crates.io-6f17d22bba15001f/http-body-util-0.1.2/src/combinators/map_err.rs:62:15
36: as http_body::Body>::poll_frame
at /home/opc/.cargo/registry/src/index.crates.io-6f17d22bba15001f/http-body-util-0.1.2/src/combinators/box_body.rs:103:9
37: ::poll_frame
at /home/opc/.cargo/registry/src/index.crates.io-6f17d22bba15001f/axum-core-0.4.3/src/body.rs:122:9
38: hyper::proto::h1::dispatch::Dispatcher::poll_write
at /home/opc/.cargo/registry/src/index.crates.io-6f17d22bba15001f/hyper-1.4.1/src/proto/h1/dispatch.rs:373:39
39: hyper::proto::h1::dispatch::Dispatcher::poll_loop
at /home/opc/.cargo/registry/src/index.crates.io-6f17d22bba15001f/hyper-1.4.1/src/proto/h1/dispatch.rs:173:21
40: hyper::proto::h1::dispatch::Dispatcher::poll_inner
at /home/opc/.cargo/registry/src/index.crates.io-6f17d22bba15001f/hyper-1.4.1/src/proto/h1/dispatch.rs:149:16
41: hyper::proto::h1::dispatch::Dispatcher::poll_catch
at /home/opc/.cargo/registry/src/index.crates.io-6f17d22bba15001f/hyper-1.4.1/src/proto/h1/dispatch.rs:128:28
42: as core::future::future::Future>::poll
at /home/opc/.cargo/registry/src/index.crates.io-6f17d22bba15001f/hyper-1.4.1/src/proto/h1/dispatch.rs:471:9
43: as core::future::future::Future>::poll
at /home/opc/.cargo/registry/src/index.crates.io-6f17d22bba15001f/hyper-1.4.1/src/server/conn/http1.rs:511:26
44: as core::future::future::Future>::poll
at /home/opc/.cargo/registry/src/index.crates.io-6f17d22bba15001f/hyper-util-0.1.7/src/server/conn/auto.rs:593:28
45: as core::future::into_future::IntoFuture>::into_future::{{closure}}::{{closure}}
at /home/opc/.cargo/registry/src/index.crates.io-6f17d22bba15001f/axum-0.7.5/src/serve.rs:218:26
46: tokio::runtime::task::core::Core::poll::{{closure}}
at /home/opc/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/task/core.rs:331:17
47: tokio::loom::std::unsafe_cell::UnsafeCell::with_mut
at /home/opc/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/loom/std/unsafe_cell.rs:16:9
48: tokio::runtime::task::core::Core::poll
at /home/opc/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/task/core.rs:320:13
49: tokio::runtime::task::harness::poll_future::{{closure}}
at /home/opc/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/task/harness.rs:500:19
50: as core::ops::function::FnOnce<()>>::call_once
at /rustc/0d634185dfddefe09047881175f35c65d68dcff1/library/core/src/panic/unwind_safe.rs:272:9
51: std::panicking::try::do_call
at /rustc/0d634185dfddefe09047881175f35c65d68dcff1/library/std/src/panicking.rs:554:40
52: __rust_try
53: std::panicking::try
at /rustc/0d634185dfddefe09047881175f35c65d68dcff1/library/std/src/panicking.rs:518:19
54: std::panic::catch_unwind
at /rustc/0d634185dfddefe09047881175f35c65d68dcff1/library/std/src/panic.rs:345:14
55: tokio::runtime::task::harness::poll_future
at /home/opc/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/task/harness.rs:488:18
56: tokio::runtime::task::harness::Harness::poll_inner
at /home/opc/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/task/harness.rs:209:27
57: tokio::runtime::task::harness::Harness::poll
at /home/opc/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/task/harness.rs:154:15
58: tokio::runtime::task::raw::poll
at /home/opc/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/task/raw.rs:271:5
59: tokio::runtime::task::raw::RawTask::poll
at /home/opc/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/task/raw.rs:201:18
60: tokio::runtime::task::LocalNotified ::run at /home/opc/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/task/mod.rs:436:9 61: tokio::runtime::scheduler::multi_thread::worker::Context::run_task::{{closure}} at /home/opc/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/scheduler/multi_thread/worker.rs:661:17 62: tokio::runtime::coop::with_budget at /home/opc/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/coop.rs:107:5 63: tokio::runtime::coop::budget at /home/opc/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/coop.rs:73:5 64: tokio::runtime::scheduler::multi_thread::worker::Context::run_task at /home/opc/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/scheduler/multi_thread/worker.rs:597:9 65: tokio::runtime::scheduler::multi_thread::worker::Context::run at /home/opc/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/scheduler/multi_thread/worker.rs:560:24 66: tokio::runtime::scheduler::multi_thread::worker::run::{{closure}}::{{closure}} at /home/opc/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/scheduler/multi_thread/worker.rs:513:21 67: tokio::runtime::context::scoped::Scoped::set
at /home/opc/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/context/scoped.rs:40:9
68: tokio::runtime::context::set_scheduler::{{closure}}
at /home/opc/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/context.rs:180:26
69: std::thread::local::LocalKey::try_with
at /rustc/0d634185dfddefe09047881175f35c65d68dcff1/library/std/src/thread/local.rs:283:12
70: std::thread::local::LocalKey::with
at /rustc/0d634185dfddefe09047881175f35c65d68dcff1/library/std/src/thread/local.rs:260:9
71: tokio::runtime::context::set_scheduler
at /home/opc/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/context.rs:180:9
72: tokio::runtime::scheduler::multi_thread::worker::run::{{closure}}
at /home/opc/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/scheduler/multi_thread/worker.rs:508:9
73: tokio::runtime::context::runtime::enter_runtime
at /home/opc/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/context/runtime.rs:65:16
74: tokio::runtime::scheduler::multi_thread::worker::run
at /home/opc/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/scheduler/multi_thread/worker.rs:500:5
75: tokio::runtime::scheduler::multi_thread::worker::Launch::launch::{{closure}}
at /home/opc/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/scheduler/multi_thread/worker.rs:466:45
76: as core::future::future::Future>::poll
at /home/opc/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/blocking/task.rs:42:21
77: tokio::runtime::task::core::Core::poll::{{closure}}
at /home/opc/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/task/core.rs:331:17
78: tokio::loom::std::unsafe_cell::UnsafeCell::with_mut
at /home/opc/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/loom/std/unsafe_cell.rs:16:9
79: tokio::runtime::task::core::Core::poll
at /home/opc/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/task/core.rs:320:13
80: tokio::runtime::task::harness::poll_future::{{closure}}
at /home/opc/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/task/harness.rs:500:19
81: as core::ops::function::FnOnce<()>>::call_once
at /rustc/0d634185dfddefe09047881175f35c65d68dcff1/library/core/src/panic/unwind_safe.rs:272:9
82: std::panicking::try::do_call
at /rustc/0d634185dfddefe09047881175f35c65d68dcff1/library/std/src/panicking.rs:554:40
83: __rust_try
84: std::panicking::try
at /rustc/0d634185dfddefe09047881175f35c65d68dcff1/library/std/src/panicking.rs:518:19
85: std::panic::catch_unwind
at /rustc/0d634185dfddefe09047881175f35c65d68dcff1/library/std/src/panic.rs:345:14
86: tokio::runtime::task::harness::poll_future
at /home/opc/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/task/harness.rs:488:18
87: tokio::runtime::task::harness::Harness::poll_inner
at /home/opc/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/task/harness.rs:209:27
88: tokio::runtime::task::harness::Harness::poll
at /home/opc/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/task/harness.rs:154:15
89: tokio::runtime::task::raw::poll
at /home/opc/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/task/raw.rs:271:5
90: tokio::runtime::task::raw::RawTask::poll
at /home/opc/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/task/raw.rs:201:18
91: tokio::runtime::task::UnownedTask ::run at /home/opc/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/task/mod.rs:473:9 92: tokio::runtime::blocking::pool::Task::run at /home/opc/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/blocking/pool.rs:160:9 93: tokio::runtime::blocking::pool::Inner::run at /home/opc/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/blocking/pool.rs:518:17 94: tokio::runtime::blocking::pool::Spawner::spawn_thread::{{closure}} at /home/opc/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/blocking/pool.rs:476:13 note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace. ```