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

Using <noscript> in SSR causes an Option.unwrap() panic during hydration #3360

Closed
azriel91 opened this issue Dec 14, 2024 · 0 comments
Closed

Comments

@azriel91
Copy link
Contributor

azriel91 commented Dec 14, 2024

Describe the bug

Using <noscript><p>"hello"</p></noscript> in SSR causes a panic during hydration.

Leptos Dependencies

leptos = { version = "0.7" }
leptos_meta = { version = "0.7" }
leptos_actix = { version = "0.7", optional = true }
leptos_router = { version = "0.7" }

To Reproduce

  1. Clone the MCVE repo:

    git clone git@github.com:azriel91/leptos_noscript.git
    cd leptos_noscript
    cargo leptos serve -v
  2. Open http://127.0.0.1:3000.

Expected behavior

Nothing! i.e. no error appears 😄.

Actual behavior:

panicked at C:\Users\azrielh\.cargo\registry\src\index.crates.io-6f17d22bba15001f\tachys-0.1.0\src\html\mod.rs:158:14:
called `Option::unwrap()` on a `None` value

The unwrap() is this one:

https://github.com/leptos-rs/leptos/blob/v0.7.0/tachys/src/html/mod.rs#L157-L158

let el = crate::renderer::types::Element::cast_from(cursor.current())
.unwrap();


Understandably hydration requires all elements to be consistent on both the server and client side, so having the browser not insert an element when scripts are not enabled would break it.

I couldn't find if there's a way for browsers to send "noscript is enabled" built-in. Maybe something like that could be written into the hydration?

This was particularly difficult to figure out 🫠, but the (A, B, C)-like tuples in the stack trace helped me traverse the view! element structure, so am glad there's some diagnostic support.

Full stack trace
panicked at C:\Users\azrielh\.cargo\registry\src\index.crates.io-6f17d22bba15001f\tachys-0.1.0\src\html\mod.rs:158:14:
called `Option::unwrap()` on a `None` value

Stack:

__wbg_get_imports/imports.wbg.__wbg_new_abda76e883ba8a5f@http://127.0.0.1:3000/pkg/leptos_noscript.js:446:13
leptos_noscript.wasm.__wbg_new_abda76e883ba8a5f externref shim@http://127.0.0.1:3000/pkg/leptos_noscript.wasm:wasm-function[10698]:0x23f205
leptos_noscript.wasm.console_error_panic_hook::Error::new::h033d2f43ec537c7d@http://127.0.0.1:3000/pkg/leptos_noscript.wasm:wasm-function[6746]:0x2066df
leptos_noscript.wasm.console_error_panic_hook::hook_impl::h39067a3aabadc55d@http://127.0.0.1:3000/pkg/leptos_noscript.wasm:wasm-function[1402]:0x112d0a
leptos_noscript.wasm.console_error_panic_hook::hook::hb32d13942e6c9a75@http://127.0.0.1:3000/pkg/leptos_noscript.wasm:wasm-function[9292]:0x2303c4
leptos_noscript.wasm.core::ops::function::Fn::call::he555abf647a4358f@http://127.0.0.1:3000/pkg/leptos_noscript.wasm:wasm-function[8081]:0x21f19a
leptos_noscript.wasm.std::panicking::rust_panic_with_hook::h497cea86a09a7edc@http://127.0.0.1:3000/pkg/leptos_noscript.wasm:wasm-function[3576]:0x1a2593
leptos_noscript.wasm.std::panicking::begin_panic_handler::{{closure}}::h458a65591e480305@http://127.0.0.1:3000/pkg/leptos_noscript.wasm:wasm-function[4343]:0x1c33be
leptos_noscript.wasm.std::sys::backtrace::__rust_end_short_backtrace::h15e16a6856b1832c@http://127.0.0.1:3000/pkg/leptos_noscript.wasm:wasm-function[10896]:0x23fd00
leptos_noscript.wasm.rust_begin_unwind@http://127.0.0.1:3000/pkg/leptos_noscript.wasm:wasm-function[10141]:0x23ad6c
leptos_noscript.wasm.core::panicking::panic_fmt::h5d640e37d63f51c5@http://127.0.0.1:3000/pkg/leptos_noscript.wasm:wasm-function[10142]:0x23ad98
leptos_noscript.wasm.core::panicking::panic::h97a28a99e9155c5a@http://127.0.0.1:3000/pkg/leptos_noscript.wasm:wasm-function[8368]:0x2239d9
leptos_noscript.wasm.core::option::unwrap_failed::hc3ad67e125f82d79@http://127.0.0.1:3000/pkg/leptos_noscript.wasm:wasm-function[10788]:0x23f833
leptos_noscript.wasm.<tachys::html::InertElement as tachys::view::RenderHtml>::hydrate::hef8001db85abbcb3@http://127.0.0.1:3000/pkg/leptos_noscript.wasm:wasm-function[1931]:0x1400e2
leptos_noscript.wasm.tachys::view::tuples::<impl tachys::view::RenderHtml for (A,)>::hydrate::h769ad584b0f1d54d@http://127.0.0.1:3000/pkg/leptos_noscript.wasm:wasm-function[4464]:0x1c7b61
leptos_noscript.wasm.<tachys::html::element::HtmlElement<E,At,Ch> as tachys::view::RenderHtml>::hydrate::h297549e91f91bb94@http://127.0.0.1:3000/pkg/leptos_noscript.wasm:wasm-function[787]:0xc9dc8
leptos_noscript.wasm.tachys::view::tuples::<impl tachys::view::RenderHtml for (A,B,C)>::hydrate::hbb7d056360be21ae@http://127.0.0.1:3000/pkg/leptos_noscript.wasm:wasm-function[485]:0x93699
leptos_noscript.wasm.<leptos::into_view::View<T> as tachys::view::RenderHtml>::hydrate::hd655379d082d1438@http://127.0.0.1:3000/pkg/leptos_noscript.wasm:wasm-function[4896]:0x1d61f7
leptos_noscript.wasm.<T as tachys::view::any_view::IntoAny>::into_any::{{closure}}::h3d405725c243e843@http://127.0.0.1:3000/pkg/leptos_noscript.wasm:wasm-function[607]:0xac4dc
leptos_noscript.wasm.core::ops::function::FnOnce::call_once::h2575483936e0fa8b@http://127.0.0.1:3000/pkg/leptos_noscript.wasm:wasm-function[4958]:0x1d80a8
leptos_noscript.wasm.<tachys::view::any_view::AnyView as tachys::view::RenderHtml>::hydrate::h087c7afabd869161@http://127.0.0.1:3000/pkg/leptos_noscript.wasm:wasm-function[6637]:0x20421b
leptos_noscript.wasm.<tachys::reactive_graph::owned::OwnedView<T> as tachys::view::RenderHtml>::hydrate::{{closure}}::h409de6afb0e4b343@http://127.0.0.1:3000/pkg/leptos_noscript.wasm:wasm-function[2172]:0x151c5c
leptos_noscript.wasm.reactive_graph::owner::Owner::with::h752e4d5ea4cde5e7@http://127.0.0.1:3000/pkg/leptos_noscript.wasm:wasm-function[3668]:0x1a6953
leptos_noscript.wasm.<tachys::reactive_graph::owned::OwnedView<T> as tachys::view::RenderHtml>::hydrate::h6e0cb27051fe940f@http://127.0.0.1:3000/pkg/leptos_noscript.wasm:wasm-function[1343]:0x10cfc6
leptos_noscript.wasm.<T as tachys::view::any_view::IntoAny>::into_any::{{closure}}::hf08796b20fb2c9fd@http://127.0.0.1:3000/pkg/leptos_noscript.wasm:wasm-function[449]:0x8b149
leptos_noscript.wasm.core::ops::function::FnOnce::call_once::hacad37044b789433@http://127.0.0.1:3000/pkg/leptos_noscript.wasm:wasm-function[4961]:0x1d8222
leptos_noscript.wasm.<tachys::view::any_view::AnyView as tachys::view::RenderHtml>::hydrate::h087c7afabd869161@http://127.0.0.1:3000/pkg/leptos_noscript.wasm:wasm-function[6637]:0x20421b
leptos_noscript.wasm.tachys::view::either::<impl tachys::view::RenderHtml for either_of::Either<A,B>>::hydrate::h43eb1dbc28eae09e@http://127.0.0.1:3000/pkg/leptos_noscript.wasm:wasm-function[1011]:0xe7aa3
leptos_noscript.wasm.tachys::view::iterators::<impl tachys::view::RenderHtml for core::option::Option<T>>::hydrate::hb557840cfd14d66f@http://127.0.0.1:3000/pkg/leptos_noscript.wasm:wasm-function[806]:0xcc9e1
leptos_noscript.wasm.<tachys::reactive_graph::suspense::Suspend<T> as tachys::view::RenderHtml>::hydrate::he526635e2e7870d3@http://127.0.0.1:3000/pkg/leptos_noscript.wasm:wasm-function[272]:0x56920
leptos_noscript.wasm.tachys::reactive_graph::<impl tachys::view::RenderHtml for F>::hydrate::{{closure}}::h96be5faf72bb862d@http://127.0.0.1:3000/pkg/leptos_noscript.wasm:wasm-function[1383]:0x110f86
leptos_noscript.wasm.<alloc::boxed::Box<F,A> as core::ops::function::FnMut<Args>>::call_mut::h54085ba2b15ff57c@http://127.0.0.1:3000/pkg/leptos_noscript.wasm:wasm-function[6428]:0x1ff830
leptos_noscript.wasm.reactive_graph::effect::render_effect::RenderEffect<T>::new_with_value::erased::{{closure}}::{{closure}}::{{closure}}::hda71721c34ad62ae@http://127.0.0.1:3000/pkg/leptos_noscript.wasm:wasm-function[7225]:0x210253
leptos_noscript.wasm.<reactive_graph::graph::subscriber::AnySubscriber as reactive_graph::graph::subscriber::WithObserver>::with_observer::h944e68ea30500868@http://127.0.0.1:3000/pkg/leptos_noscript.wasm:wasm-function[2919]:0x1808a0
leptos_noscript.wasm.reactive_graph::effect::render_effect::RenderEffect<T>::new_with_value::erased::{{closure}}::{{closure}}::hcf013fe5c895a2b9@http://127.0.0.1:3000/pkg/leptos_noscript.wasm:wasm-function[4616]:0x1cd039
leptos_noscript.wasm.reactive_graph::owner::Owner::with::hbd45879603299450@http://127.0.0.1:3000/pkg/leptos_noscript.wasm:wasm-function[3498]:0x19e9f5
leptos_noscript.wasm.reactive_graph::effect::render_effect::RenderEffect<T>::new_with_value::erased::{{closure}}::h6f301477e19336d4@http://127.0.0.1:3000/pkg/leptos_noscript.wasm:wasm-function[5368]:0x1e4166
leptos_noscript.wasm.core::bool::<impl bool>::then::hfc2fcc800926b002@http://127.0.0.1:3000/pkg/leptos_noscript.wasm:wasm-function[3729]:0x1a95fb
leptos_noscript.wasm.reactive_graph::effect::render_effect::RenderEffect<T>::new_with_value::erased::h6410d215c1091253@http://127.0.0.1:3000/pkg/leptos_noscript.wasm:wasm-function[330]:0x6b0e5
leptos_noscript.wasm.reactive_graph::effect::render_effect::RenderEffect<T>::new_with_value::h47f4e3b2d756beae@http://127.0.0.1:3000/pkg/leptos_noscript.wasm:wasm-function[4463]:0x1c7abb
leptos_noscript.wasm.reactive_graph::effect::render_effect::RenderEffect<T>::new::hf3f205f42de9ed75@http://127.0.0.1:3000/pkg/leptos_noscript.wasm:wasm-function[5069]:0x1db5e5
leptos_noscript.wasm.tachys::reactive_graph::<impl tachys::view::RenderHtml for F>::hydrate::h0be76816e5226e08@http://127.0.0.1:3000/pkg/leptos_noscript.wasm:wasm-function[4060]:0x1b7ed5
leptos_noscript.wasm.<T as tachys::view::any_view::IntoAny>::into_any::{{closure}}::h4405ddfce3168196@http://127.0.0.1:3000/pkg/leptos_noscript.wasm:wasm-function[1435]:0x1161bc
leptos_noscript.wasm.core::ops::function::FnOnce::call_once::h2995b6057b260938@http://127.0.0.1:3000/pkg/leptos_noscript.wasm:wasm-function[4959]:0x1d8126
leptos_noscript.wasm.<tachys::view::any_view::AnyView as tachys::view::RenderHtml>::hydrate::h087c7afabd869161@http://127.0.0.1:3000/pkg/leptos_noscript.wasm:wasm-function[6637]:0x20421b
leptos_noscript.wasm.tachys::view::either::<impl tachys::view::RenderHtml for either_of::EitherOf3<A,B,C>>::hydrate::h8b98f35658c948a9@http://127.0.0.1:3000/pkg/leptos_noscript.wasm:wasm-function[287]:0x5c72b
leptos_noscript.wasm.<leptos_router::nested_router::NestedRoutesView<Loc,Defs,FalFn> as tachys::view::RenderHtml>::hydrate::ha6a8b6c650f17d74@http://127.0.0.1:3000/pkg/leptos_noscript.wasm:wasm-function[188]:0x2c4e3
leptos_noscript.wasm.tachys::reactive_graph::<impl tachys::view::RenderHtml for F>::hydrate::{{closure}}::he6288f005d72b3a7@http://127.0.0.1:3000/pkg/leptos_noscript.wasm:wasm-function[601]:0xab4bf
leptos_noscript.wasm.<alloc::boxed::Box<F,A> as core::ops::function::FnMut<Args>>::call_mut::hfc3a408f200c02d7@http://127.0.0.1:3000/pkg/leptos_noscript.wasm:wasm-function[2864]:0x17d512
leptos_noscript.wasm.reactive_graph::effect::render_effect::RenderEffect<T>::new_with_value::erased::{{closure}}::{{closure}}::{{closure}}::h7fd89f5010d99665@http://127.0.0.1:3000/pkg/leptos_noscript.wasm:wasm-function[1175]:0xfaf1b
leptos_noscript.wasm.<reactive_graph::graph::subscriber::AnySubscriber as reactive_graph::graph::subscriber::WithObserver>::with_observer::h0797265817e9344e@http://127.0.0.1:3000/pkg/leptos_noscript.wasm:wasm-function[3144]:0x18ccb6
leptos_noscript.wasm.reactive_graph::effect::render_effect::RenderEffect<T>::new_with_value::erased::{{closure}}::{{closure}}::h30729360432953a4@http://127.0.0.1:3000/pkg/leptos_noscript.wasm:wasm-function[1609]:0x12607a
leptos_noscript.wasm.reactive_graph::owner::Owner::with::h4a5bb848b97076a4@http://127.0.0.1:3000/pkg/leptos_noscript.wasm:wasm-function[3662]:0x1a64fd
leptos_noscript.wasm.reactive_graph::effect::render_effect::RenderEffect<T>::new_with_value::erased::{{closure}}::hc0b2f9173c216cfc@http://127.0.0.1:3000/pkg/leptos_noscript.wasm:wasm-function[2810]:0x17a39d
leptos_noscript.wasm.core::bool::<impl bool>::then::hf152b5f014dea35d@http://127.0.0.1:3000/pkg/leptos_noscript.wasm:wasm-function[874]:0xd6282
leptos_noscript.wasm.reactive_graph::effect::render_effect::RenderEffect<T>::new_with_value::erased::h7da3f50a02f370a8@http://127.0.0.1:3000/pkg/leptos_noscript.wasm:wasm-function[263]:0x52bf9
leptos_noscript.wasm.reactive_graph::effect::render_effect::RenderEffect<T>::new_with_value::h3b76988dde53a1c1@http://127.0.0.1:3000/pkg/leptos_noscript.wasm:wasm-function[5000]:0x1d951e
leptos_noscript.wasm.reactive_graph::effect::render_effect::RenderEffect<T>::new::h68dc6b01bc3125f6@http://127.0.0.1:3000/pkg/leptos_noscript.wasm:wasm-function[6047]:0x1f65a5
leptos_noscript.wasm.tachys::reactive_graph::<impl tachys::view::RenderHtml for F>::hydrate::h04b3b2e2e4fe6819@http://127.0.0.1:3000/pkg/leptos_noscript.wasm:wasm-function[3083]:0x189916
leptos_noscript.wasm.tachys::view::tuples::<impl tachys::view::RenderHtml for (A,)>::hydrate::h47b40b8ab687cfd3@http://127.0.0.1:3000/pkg/leptos_noscript.wasm:wasm-function[4726]:0x1d09c3
leptos_noscript.wasm.<tachys::html::element::HtmlElement<E,At,Ch> as tachys::view::RenderHtml>::hydrate::hd38223f6dde8133b@http://127.0.0.1:3000/pkg/leptos_noscript.wasm:wasm-function[643]:0xb2e6b
leptos_noscript.wasm.tachys::view::tuples::<impl tachys::view::RenderHtml for (A,B)>::hydrate::hc1b42e3e2c05fea6@http://127.0.0.1:3000/pkg/leptos_noscript.wasm:wasm-function[807]:0xccb3a
leptos_noscript.wasm.<leptos::into_view::View<T> as tachys::view::RenderHtml>::hydrate::h5a6a1c2254d7ffbb@http://127.0.0.1:3000/pkg/leptos_noscript.wasm:wasm-function[5945]:0x1f3c2d
leptos_noscript.wasm.tachys::view::tuples::<impl tachys::view::RenderHtml for (A,B,C)>::hydrate::h35fede52f72cd084@http://127.0.0.1:3000/pkg/leptos_noscript.wasm:wasm-function[333]:0x6c00c
leptos_noscript.wasm.<leptos::into_view::View<T> as tachys::view::RenderHtml>::hydrate::h33015867f0e6a77e@http://127.0.0.1:3000/pkg/leptos_noscript.wasm:wasm-function[4894]:0x1d60fb
leptos_noscript.wasm.<leptos::into_view::View<T> as tachys::view::RenderHtml>::hydrate::h61ef6a04fee88573@http://127.0.0.1:3000/pkg/leptos_noscript.wasm:wasm-function[4895]:0x1d617a
leptos_noscript.wasm.leptos::mount::hydrate_from::{{closure}}::he592b97ccc644dcc@http://127.0.0.1:3000/pkg/leptos_noscript.wasm:wasm-function[3059]:0x1884d4
leptos_noscript.wasm.reactive_graph::owner::Owner::with::h3de10016254ad512@http://127.0.0.1:3000/pkg/leptos_noscript.wasm:wasm-function[3540]:0x1a0a1e
leptos_noscript.wasm.leptos::mount::hydrate_from::heed88fce4e36fb3a@http://127.0.0.1:3000/pkg/leptos_noscript.wasm:wasm-function[684]:0xb9d78
leptos_noscript.wasm.leptos::mount::hydrate_body::h16bd71e15ec61b8c@http://127.0.0.1:3000/pkg/leptos_noscript.wasm:wasm-function[8068]:0x21ee28
leptos_noscript.wasm.leptos_noscript::hydrate::h36ec85d58bed8073@http://127.0.0.1:3000/pkg/leptos_noscript.wasm:wasm-function[10877]:0x23fc54
leptos_noscript.wasm.hydrate@http://127.0.0.1:3000/pkg/leptos_noscript.wasm:wasm-function[8917]:0x22b668
hydrate@http://127.0.0.1:3000/pkg/leptos_noscript.js:227:6
@http://127.0.0.1:3000/:5:9


leptos_noscript.js:440:9
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

1 participant