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

[0.7] Panic at HtmlElement::hydrate #2953

Open
osmano807 opened this issue Sep 8, 2024 · 3 comments
Open

[0.7] Panic at HtmlElement::hydrate #2953

osmano807 opened this issue Sep 8, 2024 · 3 comments

Comments

@osmano807
Copy link

osmano807 commented Sep 8, 2024

Describe the bug
When trying to debug another bug, I stumbled upon a panic at tachys/src/html/element/mod.rs:382:61

panicked at /home/opc/.cargo/git/checkouts/leptos-2c8932a5258b3db6/4dea1195e233/tachys/src/html/element/mod.rs:382:61:
called `Option::unwrap()` on a `None` value

The bug manifests when I comment an unused variable in a component, don't know how could this be influencing. Tested on debug profile.

Leptos Dependencies
Git revision 4dea119

leptos = { git = "https://github.com/leptos-rs/leptos", features = ["nightly"] }
leptos_meta = { git = "https://github.com/leptos-rs/leptos" }
leptos_router = { git = "https://github.com/leptos-rs/leptos", features = [
  "nightly",
] }
leptos_axum = { git = "https://github.com/leptos-rs/leptos", optional = true }

To Reproduce
Steps to reproduce the behavior:

  1. Fetch this app.rs from gist
  2. Make sure line 120 is commented
  3. Navigate to "/bug"
  4. See error

Expected behavior
Page loaded without panics

Error Backtrace

panicked at /home/opc/.cargo/git/checkouts/leptos-2c8932a5258b3db6/4dea1195e233/tachys/src/html/element/mod.rs:382:61:
called `Option::unwrap()` on a `None` value
Stack:

__wbg_get_imports/imports.wbg.__wbg_new_abda76e883ba8a5f@http://127.0.0.1:8000/pkg/hydration-bug.js:504:13
hydration_bug.wasm.console_error_panic_hook::Error::new::h7b7572d73f284afa@http://127.0.0.1:8000/pkg/hydration-bug.wasm:wasm-function[9684]:0x2f376f
hydration_bug.wasm.console_error_panic_hook::hook_impl::h62942ff88aa73d80@http://127.0.0.1:8000/pkg/hydration-bug.wasm:wasm-function[1935]:0x1927a3
hydration_bug.wasm.console_error_panic_hook::hook::h9db2d13d16da4a02@http://127.0.0.1:8000/pkg/hydration-bug.wasm:wasm-function[13362]:0x32e616
hydration_bug.wasm.core::ops::function::Fn::call::h5c6c8b5691e120c8@http://127.0.0.1:8000/pkg/hydration-bug.wasm:wasm-function[11424]:0x313689
hydration_bug.wasm.std::panicking::rust_panic_with_hook::hc9cd60fe9812da23@http://127.0.0.1:8000/pkg/hydration-bug.wasm:wasm-function[4587]:0x248e65
hydration_bug.wasm.std::panicking::begin_panic_handler::{{closure}}::haa86e9272bd77712@http://127.0.0.1:8000/pkg/hydration-bug.wasm:wasm-function[6294]:0x2954b7
hydration_bug.wasm.std::sys::backtrace::__rust_end_short_backtrace::h6cb463b13760fa25@http://127.0.0.1:8000/pkg/hydration-bug.wasm:wasm-function[15162]:0x33fae5
hydration_bug.wasm.rust_begin_unwind@http://127.0.0.1:8000/pkg/hydration-bug.wasm:wasm-function[10197]:0x2fdda3
hydration_bug.wasm.core::panicking::panic_fmt::h13605b54665beab4@http://127.0.0.1:8000/pkg/hydration-bug.wasm:wasm-function[10622]:0x305cc9
hydration_bug.wasm.core::panicking::panic::hc9e73afd699ebacf@http://127.0.0.1:8000/pkg/hydration-bug.wasm:wasm-function[11817]:0x319968
hydration_bug.wasm.core::option::unwrap_failed::hc2750e81e870cc85@http://127.0.0.1:8000/pkg/hydration-bug.wasm:wasm-function[15050]:0x33f5fb
hydration_bug.wasm.<tachys::html::element::HtmlElement<E,At,Ch,Rndr> as tachys::view::RenderHtml<Rndr>>::hydrate::hb2994385a72a2b4c@http://127.0.0.1:8000/pkg/hydration-bug.wasm:wasm-function[1246]:0x142a5c
hydration_bug.wasm.<leptos::into_view::View<T> as tachys::view::RenderHtml<Rndr>>::hydrate::h8f026d03d103b4a5@http://127.0.0.1:8000/pkg/hydration-bug.wasm:wasm-function[10367]:0x3011ed
hydration_bug.wasm.<tachys::view::either::EitherKeepAlive<A,B> as tachys::view::RenderHtml<Rndr>>::hydrate::{{closure}}::h3ad0a944fe551c51@http://127.0.0.1:8000/pkg/hydration-bug.wasm:wasm-function[10800]:0x308e91
hydration_bug.wasm.core::option::Option<T>::map::h3c80210d0887d804@http://127.0.0.1:8000/pkg/hydration-bug.wasm:wasm-function[1924]:0x191783
hydration_bug.wasm.<tachys::view::either::EitherKeepAlive<A,B> as tachys::view::RenderHtml<Rndr>>::hydrate::h015eba3db23ce7d1@http://127.0.0.1:8000/pkg/hydration-bug.wasm:wasm-function[718]:0xec091
hydration_bug.wasm.<tachys::reactive_graph::owned::OwnedView<T,R> as tachys::view::RenderHtml<R>>::hydrate::{{closure}}::h5e90bd4a1867e907@http://127.0.0.1:8000/pkg/hydration-bug.wasm:wasm-function[2439]:0x1be7fb
hydration_bug.wasm.reactive_graph::owner::Owner::with::he563420b90c6f059@http://127.0.0.1:8000/pkg/hydration-bug.wasm:wasm-function[5326]:0x26cee2
hydration_bug.wasm.<tachys::reactive_graph::owned::OwnedView<T,R> as tachys::view::RenderHtml<R>>::hydrate::h73122a7d818b9aaf@http://127.0.0.1:8000/pkg/hydration-bug.wasm:wasm-function[1156]:0x135f21
hydration_bug.wasm.<leptos::suspense_component::SuspenseBoundary<_,Fal,Chil> as tachys::view::RenderHtml<Rndr>>::hydrate::{{closure}}::h1f0ffa78d5ecd888@http://127.0.0.1:8000/pkg/hydration-bug.wasm:wasm-function[565]:0xc8ed7
hydration_bug.wasm.<alloc::boxed::Box<F,A> as core::ops::function::FnMut<Args>>::call_mut::hdf940d41e60a4264@http://127.0.0.1:8000/pkg/hydration-bug.wasm:wasm-function[8997]:0x2e424e
hydration_bug.wasm.reactive_graph::effect::render_effect::RenderEffect<T>::new_with_value::erased::{{closure}}::{{closure}}::{{closure}}::h4b1dbc2c07186b65@http://127.0.0.1:8000/pkg/hydration-bug.wasm:wasm-function[7616]:0x2bfba2
hydration_bug.wasm.<reactive_graph::graph::subscriber::AnySubscriber as reactive_graph::graph::subscriber::WithObserver>::with_observer::hfc081f04f48f3c10@http://127.0.0.1:8000/pkg/hydration-bug.wasm:wasm-function[4555]:0x24737a
hydration_bug.wasm.reactive_graph::effect::render_effect::RenderEffect<T>::new_with_value::erased::{{closure}}::{{closure}}::h10a3c7d672617835@http://127.0.0.1:8000/pkg/hydration-bug.wasm:wasm-function[5548]:0x276c9f
hydration_bug.wasm.reactive_graph::owner::Owner::with::hbf28f002125f67b1@http://127.0.0.1:8000/pkg/hydration-bug.wasm:wasm-function[5317]:0x26c861
hydration_bug.wasm.reactive_graph::effect::render_effect::RenderEffect<T>::new_with_value::erased::{{closure}}::h4a3b88603b1e8788@http://127.0.0.1:8000/pkg/hydration-bug.wasm:wasm-function[8499]:0x2d7c81
hydration_bug.wasm.core::bool::<impl bool>::then::h2d50c8750fe320af@http://127.0.0.1:8000/pkg/hydration-bug.wasm:wasm-function[5498]:0x2748c6
hydration_bug.wasm.reactive_graph::effect::render_effect::RenderEffect<T>::new_with_value::erased::ha2c92744ee039ee7@http://127.0.0.1:8000/pkg/hydration-bug.wasm:wasm-function[413]:0x9bca2
hydration_bug.wasm.reactive_graph::effect::render_effect::RenderEffect<T>::new_with_value::h2fad35bf494fe519@http://127.0.0.1:8000/pkg/hydration-bug.wasm:wasm-function[7211]:0x2b3ce4
hydration_bug.wasm.reactive_graph::effect::render_effect::RenderEffect<T>::new::h5f2bfd66b005570d@http://127.0.0.1:8000/pkg/hydration-bug.wasm:wasm-function[8693]:0x2dcbca
hydration_bug.wasm.<leptos::suspense_component::SuspenseBoundary<_,Fal,Chil> as tachys::view::RenderHtml<Rndr>>::hydrate::h9fdff28283e7479d@http://127.0.0.1:8000/pkg/hydration-bug.wasm:wasm-function[646]:0xdcc95
hydration_bug.wasm.<tachys::reactive_graph::owned::OwnedView<T,R> as tachys::view::RenderHtml<R>>::hydrate::{{closure}}::h432729eb296fceb2@http://127.0.0.1:8000/pkg/hydration-bug.wasm:wasm-function[6853]:0x2a8791
hydration_bug.wasm.reactive_graph::owner::Owner::with::hfb4dee6ee7ebce3a@http://127.0.0.1:8000/pkg/hydration-bug.wasm:wasm-function[4634]:0x24b482
hydration_bug.wasm.<tachys::reactive_graph::owned::OwnedView<T,R> as tachys::view::RenderHtml<R>>::hydrate::h65f31da2b8b11907@http://127.0.0.1:8000/pkg/hydration-bug.wasm:wasm-function[3308]:0x1fd0a8
hydration_bug.wasm.<leptos::into_view::View<T> as tachys::view::RenderHtml<Rndr>>::hydrate::h94c489602f94cc7b@http://127.0.0.1:8000/pkg/hydration-bug.wasm:wasm-function[8497]:0x2d7ba0
hydration_bug.wasm.tachys::reactive_graph::<impl tachys::view::RenderHtml<R> for F>::hydrate::{{closure}}::h95e9d6f23f52ce81@http://127.0.0.1:8000/pkg/hydration-bug.wasm:wasm-function[1262]:0x144df8
hydration_bug.wasm.<alloc::boxed::Box<F,A> as core::ops::function::FnMut<Args>>::call_mut::h09392c6c2bbb82df@http://127.0.0.1:8000/pkg/hydration-bug.wasm:wasm-function[4873]:0x2577a3
hydration_bug.wasm.reactive_graph::effect::render_effect::RenderEffect<T>::new_with_value::erased::{{closure}}::{{closure}}::{{closure}}::he66c6541378b107f@http://127.0.0.1:8000/pkg/hydration-bug.wasm:wasm-function[2979]:0x1e6ca6
hydration_bug.wasm.<reactive_graph::graph::subscriber::AnySubscriber as reactive_graph::graph::subscriber::WithObserver>::with_observer::hf6b6fa29ee3d327e@http://127.0.0.1:8000/pkg/hydration-bug.wasm:wasm-function[4554]:0x2472ae
hydration_bug.wasm.reactive_graph::effect::render_effect::RenderEffect<T>::new_with_value::erased::{{closure}}::{{closure}}::h689ba333b53cf1f4@http://127.0.0.1:8000/pkg/hydration-bug.wasm:wasm-function[3229]:0x1f7d4e
hydration_bug.wasm.reactive_graph::owner::Owner::with::hd3cb86a4fc0c514c@http://127.0.0.1:8000/pkg/hydration-bug.wasm:wasm-function[5320]:0x26ca8c
hydration_bug.wasm.reactive_graph::effect::render_effect::RenderEffect<T>::new_with_value::erased::{{closure}}::haac702ce29a2746e@http://127.0.0.1:8000/pkg/hydration-bug.wasm:wasm-function[4351]:0x23c696
hydration_bug.wasm.core::bool::<impl bool>::then::ha75a5df94fab9d22@http://127.0.0.1:8000/pkg/hydration-bug.wasm:wasm-function[2009]:0x199a01
hydration_bug.wasm.reactive_graph::effect::render_effect::RenderEffect<T>::new_with_value::erased::hb9bee53da3ddba6b@http://127.0.0.1:8000/pkg/hydration-bug.wasm:wasm-function[346]:0x84254
hydration_bug.wasm.reactive_graph::effect::render_effect::RenderEffect<T>::new_with_value::h31fbb21347b6b372@http://127.0.0.1:8000/pkg/hydration-bug.wasm:wasm-function[6244]:0x29362d
hydration_bug.wasm.reactive_graph::effect::render_effect::RenderEffect<T>::new::hf6c93bb0258d2678@http://127.0.0.1:8000/pkg/hydration-bug.wasm:wasm-function[7058]:0x2af1c6
hydration_bug.wasm.tachys::reactive_graph::<impl tachys::view::RenderHtml<R> for F>::hydrate::ha6740f3989417a44@http://127.0.0.1:8000/pkg/hydration-bug.wasm:wasm-function[5829]:0x282e66
hydration_bug.wasm.tachys::view::tuples::<impl tachys::view::RenderHtml<Rndr> for (A,B)>::hydrate::hb8d11a65cc868bed@http://127.0.0.1:8000/pkg/hydration-bug.wasm:wasm-function[6688]:0x2a3163
hydration_bug.wasm.<leptos::into_view::View<T> as tachys::view::RenderHtml<Rndr>>::hydrate::h0470106da65aadf8@http://127.0.0.1:8000/pkg/hydration-bug.wasm:wasm-function[11188]:0x30f7ff
hydration_bug.wasm.tachys::view::either::<impl tachys::view::RenderHtml<Rndr> for either_of::Either<A,B>>::hydrate::hac05de21787a92bc@http://127.0.0.1:8000/pkg/hydration-bug.wasm:wasm-function[2087]:0x1a0c87
hydration_bug.wasm.<tachys::reactive_graph::owned::OwnedView<T,R> as tachys::view::RenderHtml<R>>::hydrate::{{closure}}::ha73bfa8fa47fde42@http://127.0.0.1:8000/pkg/hydration-bug.wasm:wasm-function[9820]:0x2f6529
hydration_bug.wasm.reactive_graph::owner::Owner::with::h288ad12689438501@http://127.0.0.1:8000/pkg/hydration-bug.wasm:wasm-function[5297]:0x26b9ed
hydration_bug.wasm.<tachys::reactive_graph::owned::OwnedView<T,R> as tachys::view::RenderHtml<R>>::hydrate::h5eb55477db3dcbdf@http://127.0.0.1:8000/pkg/hydration-bug.wasm:wasm-function[3341]:0x1ff3c4
hydration_bug.wasm.<T as tachys::view::any_view::IntoAny<R>>::into_any::{{closure}}::h741106c5b14ea1f8@http://127.0.0.1:8000/pkg/hydration-bug.wasm:wasm-function[1810]:0x185f7a
hydration_bug.wasm.core::ops::function::FnOnce::call_once::h3fad1f71da230cce@http://127.0.0.1:8000/pkg/hydration-bug.wasm:wasm-function[7143]:0x2b1be8
hydration_bug.wasm.<tachys::view::any_view::AnyView<R> as tachys::view::RenderHtml<R>>::hydrate::h9f2e8ba6b3e3a64d@http://127.0.0.1:8000/pkg/hydration-bug.wasm:wasm-function[9367]:0x2ecac9
hydration_bug.wasm.tachys::view::either::<impl tachys::view::RenderHtml<Rndr> for either_of::Either<A,B>>::hydrate::ha5fe87714e0e920d@http://127.0.0.1:8000/pkg/hydration-bug.wasm:wasm-function[1478]:0x1609b4
hydration_bug.wasm.tachys::view::iterators::<impl tachys::view::RenderHtml<R> for core::option::Option<T>>::hydrate::h5334ebb7ac3cb892@http://127.0.0.1:8000/pkg/hydration-bug.wasm:wasm-function[1147]:0x134b9e
hydration_bug.wasm.<tachys::reactive_graph::suspense::Suspend<Fut> as tachys::view::RenderHtml<Rndr>>::hydrate::h04e9c1103b995ccb@http://127.0.0.1:8000/pkg/hydration-bug.wasm:wasm-function[544]:0xc3420
hydration_bug.wasm.tachys::reactive_graph::<impl tachys::view::RenderHtml<R> for F>::hydrate::{{closure}}::h4e1d916da898a7ff@http://127.0.0.1:8000/pkg/hydration-bug.wasm:wasm-function[2060]:0x19e607
hydration_bug.wasm.<alloc::boxed::Box<F,A> as core::ops::function::FnMut<Args>>::call_mut::h029e3bf19fc8f661@http://127.0.0.1:8000/pkg/hydration-bug.wasm:wasm-function[9188]:0x2e8a52
hydration_bug.wasm.reactive_graph::effect::render_effect::RenderEffect<T>::new_with_value::erased::{{closure}}::{{closure}}::{{closure}}::hd749d55ac8720499@http://127.0.0.1:8000/pkg/hydration-bug.wasm:wasm-function[10210]:0x2fe188
hydration_bug.wasm.<reactive_graph::graph::subscriber::AnySubscriber as reactive_graph::graph::subscriber::WithObserver>::with_observer::h2b0790f925361c6f@http://127.0.0.1:8000/pkg/hydration-bug.wasm:wasm-function[4240]:0x236367
hydration_bug.wasm.reactive_graph::effect::render_effect::RenderEffect<T>::new_with_value::erased::{{closure}}::{{closure}}::h801180643f8728ff@http://127.0.0.1:8000/pkg/hydration-bug.wasm:wasm-function[6683]:0x2a2eb5
hydration_bug.wasm.reactive_graph::owner::Owner::with::ha18c203bcba16f73@http://127.0.0.1:8000/pkg/hydration-bug.wasm:wasm-function[5066]:0x260d0f
hydration_bug.wasm.reactive_graph::effect::render_effect::RenderEffect<T>::new_with_value::erased::{{closure}}::h51bc431400cee522@http://127.0.0.1:8000/pkg/hydration-bug.wasm:wasm-function[7712]:0x2c27e2
hydration_bug.wasm.core::bool::<impl bool>::then::h21cc862a3e5265bc@http://127.0.0.1:8000/pkg/hydration-bug.wasm:wasm-function[5444]:0x2723a5
hydration_bug.wasm.reactive_graph::effect::render_effect::RenderEffect<T>::new_with_value::erased::h6cf51d8b1eed2b7d@http://127.0.0.1:8000/pkg/hydration-bug.wasm:wasm-function[451]:0xa806a
hydration_bug.wasm.reactive_graph::effect::render_effect::RenderEffect<T>::new_with_value::h49e1595d8c589c15@http://127.0.0.1:8000/pkg/hydration-bug.wasm:wasm-function[6378]:0x298568
hydration_bug.wasm.reactive_graph::effect::render_effect::RenderEffect<T>::new::h5384f30f4bcb84e0@http://127.0.0.1:8000/pkg/hydration-bug.wasm:wasm-function[7304]:0x2b6990
hydration_bug.wasm.tachys::reactive_graph::<impl tachys::view::RenderHtml<R> for F>::hydrate::hfee4fb8eebf59993@http://127.0.0.1:8000/pkg/hydration-bug.wasm:wasm-function[5835]:0x28326e
hydration_bug.wasm.<T as tachys::view::any_view::IntoAny<R>>::into_any::{{closure}}::h900fa1bd5952130e@http://127.0.0.1:8000/pkg/hydration-bug.wasm:wasm-function[1978]:0x196a81
hydration_bug.wasm.core::ops::function::FnOnce::call_once::ha60d1480c740a9e8@http://127.0.0.1:8000/pkg/hydration-bug.wasm:wasm-function[7150]:0x2b1f4b
hydration_bug.wasm.<tachys::view::any_view::AnyView<R> as tachys::view::RenderHtml<R>>::hydrate::h9f2e8ba6b3e3a64d@http://127.0.0.1:8000/pkg/hydration-bug.wasm:wasm-function[9367]:0x2ecac9
hydration_bug.wasm.tachys::view::either::<impl tachys::view::RenderHtml<Rndr> for either_of::EitherOf3<A,B,C>>::hydrate::h8e6f8dc950dff2c5@http://127.0.0.1:8000/pkg/hydration-bug.wasm:wasm-function[534]:0xc0706
hydration_bug.wasm.<leptos_router::nested_router::NestedRoutesView<Loc,Defs,FalFn,R> as tachys::view::RenderHtml<R>>::hydrate::h23a989ae66cadc45@http://127.0.0.1:8000/pkg/hydration-bug.wasm:wasm-function[234]:0x5071c
hydration_bug.wasm.tachys::reactive_graph::<impl tachys::view::RenderHtml<R> for F>::hydrate::{{closure}}::h4daa60e0c55284b8@http://127.0.0.1:8000/pkg/hydration-bug.wasm:wasm-function[797]:0xfb687
hydration_bug.wasm.<alloc::boxed::Box<F,A> as core::ops::function::FnMut<Args>>::call_mut::he0e0bfa3ca449d2b@http://127.0.0.1:8000/pkg/hydration-bug.wasm:wasm-function[4184]:0x232e7c
hydration_bug.wasm.reactive_graph::effect::render_effect::RenderEffect<T>::new_with_value::erased::{{closure}}::{{closure}}::{{closure}}::h76548310eee0abd5@http://127.0.0.1:8000/pkg/hydration-bug.wasm:wasm-function[1591]:0x16df19
hydration_bug.wasm.<reactive_graph::graph::subscriber::AnySubscriber as reactive_graph::graph::subscriber::WithObserver>::with_observer::hec156fbce5a26bdf@http://127.0.0.1:8000/pkg/hydration-bug.wasm:wasm-function[4552]:0x247116
hydration_bug.wasm.reactive_graph::effect::render_effect::RenderEffect<T>::new_with_value::erased::{{closure}}::{{closure}}::hcf2546dba5e9926c@http://127.0.0.1:8000/pkg/hydration-bug.wasm:wasm-function[2205]:0x1ab2e3
hydration_bug.wasm.reactive_graph::owner::Owner::with::h33bef38ca0c3301f@http://127.0.0.1:8000/pkg/hydration-bug.wasm:wasm-function[5300]:0x26bc18
hydration_bug.wasm.reactive_graph::effect::render_effect::RenderEffect<T>::new_with_value::erased::{{closure}}::h096429ad8b98854d@http://127.0.0.1:8000/pkg/hydration-bug.wasm:wasm-function[4087]:0x22d517
hydration_bug.wasm.core::bool::<impl bool>::then::h3323f277f986e790@http://127.0.0.1:8000/pkg/hydration-bug.wasm:wasm-function[1282]:0x147896
hydration_bug.wasm.reactive_graph::effect::render_effect::RenderEffect<T>::new_with_value::erased::hc263c8590b037b83@http://127.0.0.1:8000/pkg/hydration-bug.wasm:wasm-function[303]:0x725f3
hydration_bug.wasm.reactive_graph::effect::render_effect::RenderEffect<T>::new_with_value::he1a0de2c17a0b6a0@http://127.0.0.1:8000/pkg/hydration-bug.wasm:wasm-function[7216]:0x2b3f55
hydration_bug.wasm.reactive_graph::effect::render_effect::RenderEffect<T>::new::hbec957651437c2b4@http://127.0.0.1:8000/pkg/hydration-bug.wasm:wasm-function[8698]:0x2dcdc2
hydration_bug.wasm.tachys::reactive_graph::<impl tachys::view::RenderHtml<R> for F>::hydrate::he8a523ecd37d0d7c@http://127.0.0.1:8000/pkg/hydration-bug.wasm:wasm-function[4437]:0x2410c2
hydration_bug.wasm.<leptos::into_view::View<T> as tachys::view::RenderHtml<Rndr>>::hydrate::h29a95c9a189cf9a6@http://127.0.0.1:8000/pkg/hydration-bug.wasm:wasm-function[6371]:0x298160
hydration_bug.wasm.<leptos::into_view::View<T> as tachys::view::RenderHtml<Rndr>>::hydrate::h8adff2170008c450@http://127.0.0.1:8000/pkg/hydration-bug.wasm:wasm-function[6373]:0x298286
hydration_bug.wasm.<leptos::into_view::View<T> as tachys::view::RenderHtml<Rndr>>::hydrate::h3bfcd75adfa917fc@http://127.0.0.1:8000/pkg/hydration-bug.wasm:wasm-function[6372]:0x2981f3
hydration_bug.wasm.leptos::mount::hydrate_from::{{closure}}::he710310cbb6177fc@http://127.0.0.1:8000/pkg/hydration-bug.wasm:wasm-function[3710]:0x216939
hydration_bug.wasm.reactive_graph::owner::Owner::with::h0c098c1aa4a95ad0@http://127.0.0.1:8000/pkg/hydration-bug.wasm:wasm-function[4243]:0x2365af
hydration_bug.wasm.leptos::mount::hydrate_from::h2caffaa3d38c1d2c@http://127.0.0.1:8000/pkg/hydration-bug.wasm:wasm-function[978]:0x11ae7f
hydration_bug.wasm.leptos::mount::hydrate_body::hcd7f9409944274fe@http://127.0.0.1:8000/pkg/hydration-bug.wasm:wasm-function[9296]:0x2eb1d2
hydration_bug.wasm.hydration_bug::hydrate::h4c422fa8ee5e2e7d@http://127.0.0.1:8000/pkg/hydration-bug.wasm:wasm-function[15060]:0x33f67c
hydration_bug.wasm.hydrate@http://127.0.0.1:8000/pkg/hydration-bug.wasm:wasm-function[12539]:0x323cd2
hydrate@http://127.0.0.1:8000/pkg/hydration-bug.js:254:6
@http://127.0.0.1:8000/bug:5:9
promise callback*@http://127.0.0.1:8000/bug:4:57
promise callback*@http://127.0.0.1:8000/bug:3:4
@http://127.0.0.1:8000/bug:8:3

Additional context
When the line 120 is uncommented, it manifests the other bug I mentioned on discord, still trying to reduce the example and pinpoint something as the cause. Experiments on https://github.com/osmano807/hydration-bug

@gbj
Copy link
Collaborator

gbj commented Sep 8, 2024

Note also that <Sidebar/> and {Sidebar} are not the same thing: the first one calls Sidebar and gives the result to the view, the second one returns the function itself. <Sidebar/> (or {Sidebar()}, which is the same thing) is nearly always what you want.

Happy to investigate the difference of course. Functions that return views are handled slightly differently from views themselves for the purpose of suspense, for complicated reasons having to do with supporting both synchronous and async resource reads in Suspense.

(This panic is just one of the ways that a hydration error manifests itself)

@osmano807
Copy link
Author

I tried these (with line 120 commented):

  1. {Sidebar}, it panics and don't have "strange data deserialization" bug.
  2. {Sidebar()}, it doesn't panic neither have the deserialization bug.
  3. {move || Sidebar}, it panics and don't have the deserialization bug.
  4. {move || Sidebar()}, it panics and don't have the deserialization bug.

I tried these (with line 120 uncommented):

  1. {Sidebar}, deserialization bug.
  2. {Sidebar()}, no deserialization bug.
  3. {move || Sidebar}, deserialization bug.
  4. {move || Sidebar()}, deserialization bug.

I tough {Sidebar()} was the same as {move || Sidebar()}, as in passing the function result vs a closure that calls the function and returns its result.

I'll experiment more on the full app and see if passing {Sidebar()} stops the strange behaviour. For now I think that was just me not knowing how view! works and what to pass to it.

@gbj
Copy link
Collaborator

gbj commented Sep 9, 2024

I tough {Sidebar()} was the same as {move || Sidebar()}, as in passing the function result vs a closure that calls the function and returns its result.

No, this is mistaken. move || Sidebar() is identical to Sidebar, the function, not to Sidebar() (calling the function). This is just a matter of Rust semantics, not the view macro.

Let's say Sidebar is a function that returns some view typ T.

  1. {Sidebar}, it panics and don't have "strange data deserialization" bug.
    A function that returns T: doesn't work.
  1. {Sidebar()}, it doesn't panic neither have the deserialization bug.
    T: it works.
  1. {move || Sidebar}, it panics and don't have the deserialization bug.
    A function that returns a function that returns T: doesn't work.
  1. {move || Sidebar()}, it panics and don't have the deserialization bug.
    A function that returns T (identical with 1): doesn't work.

The part that's specific to the view macro is that <Sidebar/> is the same as Sidebar(), not the same as Sidebar: i.e., using a component in the view actually calls the component function, it does not just pass the function.

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