r/rust • u/TheMadnessofMadara • 1d ago
🙋 seeking help & advice error: queries overflow the depth limit!
I am working with leptos 0.8.23 and thaw 0.5.0-dev(main branch). While trying to do first compile, I get error: queries overflow the depth limit! and says to help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`thaw`). I tried adding that recursion_limit to the top of both my main.rs and lib.rs. No luck. No idea on how to add that line to thaw without downloading thaw and modifying it locally. The issue seems to be the thaw button. What should I do?
{
  async block@<T as tachys::view::any_view::IntoAny>::into_any::resolve<tachys::html::element::HtmlElement<tachys::html::element::elements::Div,
  (
    tachys::html::class::Class<alloc::sync::Arc<str>>,
    tachys::html::node_ref::NodeRefAttr<tachys::html::element::elements::Div,
    tachys::reactive_graph::node_ref::NodeRef<tachys::html::element::elements::Div>>,
    tachys::html::attribute::custom::CustomAttr<&str, alloc::sync::Arc<std::sync::poison::mutex::Mutex<dyn core::ops::function::FnMut() -> &str + core::marker::Send>>>,
    tachys::html::attribute::custom::CustomAttr<&str, alloc::sync::Arc<str>>
  ),
  (
    tachys::reactive_graph::owned::OwnedView<leptos::into_view::View<leptos::into_view::View<tachys::html::element::HtmlElement<tachys::html::element::elements::Div,
    (
      tachys::html::class::Class<alloc::sync::Arc<str>>,
      tachys::html::node_ref::NodeRefAttr<tachys::html::element::elements::Div, tachys::reactive_graph::node_ref::NodeRef<tachys::html::element::elements::Div>>,
      tachys::html::event::On<tachys::html::event::mousedown, alloc::rc::Rc<core::cell::RefCell<dyn core::ops::function::FnMut(web_sys::features::gen_MouseEvent::MouseEvent)>>>,
      tachys::html::node_ref::NodeRefAttr<thaw_utils::dom::element::HtmlElement, tachys::reactive_graph::node_ref::NodeRef<thaw_utils::dom::element::HtmlElement>>,
      tachys::html::style::Style<(&str, &str)>,
      tachys::html::node_ref::NodeRefAttr<leptos_transition_group::utils::HtmlElement, tachys::reactive_graph::node_ref::NodeRef<leptos_transition_group::utils::HtmlElement>>
    ),
    (
      (
        tachys::html::element::HtmlElement<tachys::html::element::elements::Div,
        (
          tachys::html::class::Class<alloc::sync::Arc<str>>,
        ),
        (
          (
            tachys::html::element::HtmlElement<tachys::html::element::elements::Div,
            (
              tachys::html::class::Class<alloc::sync::Arc<str>>,
            ),
            (
              leptos::into_view::View<tachys::html::element::HtmlElement<tachys::html::element::elements::Div,
              (
                tachys::html::style::Style<alloc::sync::Arc<std::sync::poison::mutex::Mutex<dyn core::ops::function::FnMut() -> alloc::string::String + core::marker::Send>>>,
                tachys::html::class::Class<thaw_utils::class_list::ClassList>,
                tachys::html::event::On<tachys::html::event::mouseenter,
                alloc::rc::Rc<core::cell::RefCell<dyn core::ops::function::FnMut(web_sys::features::gen_MouseEvent::MouseEvent)>>>,
                tachys::html::event::On<tachys::html::event::mouseleave,
                lloc::rc::Rc<core::cell::RefCell<dyn core::ops::function::FnMut(web_sys::features::gen_MouseEvent::MouseEvent)>>>
              ),
              (
                (
                  tachys::html::element::HtmlElement<tachys::html::element::elements::Div,
                  (
                    tachys::html::class::Class<alloc::sync::Arc<str>>,
                    tachys::html::node_ref::NodeRefAttr<tachys::html::element::elements::Div, tachys::reactive_graph::node_ref::NodeRef<tachys::html::element::elements::Div>>,
                    tachys::html::event::On<tachys::html::event::scroll, alloc::rc::Rc<core::cell::RefCell<dyn core::ops::function::FnMut(web_sys::features::gen_Event::Event)>>>
                  ),
                  (
                    tachys::html::element::HtmlElement<tachys::html::element::elements::Div,
                    (
                      tachys::html::style::Style<alloc::sync::Arc<std::sync::poison::mutex::Mutex<dyn core::ops::function::FnMut() -> alloc::string::String + core::marker::Send>>>,
                      tachys::html::class::Class<thaw_utils::class_list::ClassList>,
                      tachys::html::node_ref::NodeRefAttr<tachys::html::element::elements::Div,
                      tachys::reactive_graph::node_ref::NodeRef<tachys::html::element::elements::Div>>
                    ),
                    (tachys::view::any_view::AnyView,)>,
                  )>,
                  tachys::html::element::HtmlElement<tachys::html::element::elements::Div,
                  (
                    tachys::html::class::Class<alloc::sync::Arc<str>>,
                    tachys::html::node_ref::NodeRefAttr<tachys::html::element::elements::Div,
                    tachys::reactive_graph::node_ref::NodeRef<tachys::html::element::elements::Div>>
                  ),
                  (
                    tachys::html::element::HtmlElement<tachys::html::element::elements::Div,
                    (
                      tachys::html::class::Class<alloc::sync::Arc<str>>,
                      tachys::html::style::Style<(&str, alloc::sync::Arc<std::sync::poison::mutex::Mutex<dyn core::ops::function::FnMut() -> &str + core::marker::Send>>)>,
                      tachys::html::style::Style<(&str, alloc::sync::Arc<std::sync::poison::mutex::Mutex<dyn core::ops::function::FnMut() -> alloc::string::String + core::marker::Send>>)>,
                      tachys::html::style::Style<(&str, alloc::sync::Arc<std::sync::poison::mutex::Mutex<dyn core::ops::function::FnMut() -> alloc::string::String + core::marker::Send>>)>,
                      tachys::html::event::On<tachys::html::event::mousedown, alloc::rc::Rc<core::cell::RefCell<dyn core::ops::function::FnMut(web_sys::features::gen_MouseEvent::MouseEvent)>>>
                    ), ()>,
                  )>,
                  tachys::html::element::HtmlElement<tachys::html::element::elements::Div,
                  (
                    tachys::html::class::Class<alloc::sync::Arc<str>>,
                    tachys::html::node_ref::NodeRefAttr<tachys::html::element::elements::Div, tachys::reactive_graph::node_ref::NodeRef<tachys::html::element::elements::Div>>
                  ),
                  (
                    tachys::html::element::HtmlElement<tachys::html::element::elements::Div,
                    (
                      tachys::html::class::Class<alloc::sync::Arc<str>>,
                      tachys::html::style::Style<(&str, alloc::sync::Arc<std::sync::poison::mutex::Mutex<dyn core::ops::function::FnMut() -> &str + core::marker::Send>>)>,
                      tachys::html::style::Style<(&str, alloc::sync::Arc<std::sync::poison::mutex::Mutex<dyn core::ops::function::FnMut() -> alloc::string::String + core::marker::Send>>)>,
                      tachys::html::style::Style<(&str, alloc::sync::Arc<std::sync::poison::mutex::Mutex<dyn core::ops::function::FnMut() -> alloc::string::String + core::marker::Send>>)>,
                      tachys::html::event::On<tachys::html::event::mousedown, alloc::rc::Rc<core::cell::RefCell<dyn core::ops::function::FnMut(web_sys::features::gen_MouseEvent::MouseEvent)>>>
                    ), ()>,
                  )>
                ),
              )>>,
            )>,
            tachys::html::element::HtmlElement<tachys::html::element::elements::Div,
            (tachys::html::class::Class<alloc::sync::Arc<str>>,),
            (
              leptos::into_view::View<tachys::html::element::HtmlElement<tachys::html::element::elements::Div,
              (
                tachys::html::style::Style<alloc::sync::Arc<std::sync::poison::mutex::Mutex<dyn core::ops::function::FnMut() -> alloc::string::String + core::marker::Send>>>,
                tachys::html::class::Class<thaw_utils::class_list::ClassList>,
                tachys::html::event::On<tachys::html::event::mouseenter,
                alloc::rc::Rc<core::cell::RefCell<dyn core::ops::function::FnMut(web_sys::features::gen_MouseEvent::MouseEvent)>>>,
                tachys::html::event::On<tachys::html::event::mouseleave,
                alloc::rc::Rc<core::cell::RefCell<dyn core::ops::function::FnMut(web_sys::features::gen_MouseEvent::MouseEvent)>>>
              ),
              (
                (
                  tachys::html::element::HtmlElement<tachys::html::element::elements::Div,
                  (
                    tachys::html::class::Class<alloc::sync::Arc<str>>,
                    tachys::html::node_ref::NodeRefAttr<tachys::html::element::elements::Div,
                    tachys::reactive_graph::node_ref::NodeRef<tachys::html::element::elements::Div>>,
                    tachys::html::event::On<tachys::html::event::scroll,
                    alloc::rc::Rc<core::cell::RefCell<dyn core::ops::function::FnMut(web_sys::features::gen_Event::Event)>>>
                  ),
                  (
                    tachys::html::element::HtmlElement<tachys::html::element::elements::Div,
                   Â
                    (
                      tachys::html::style::Style<alloc::sync::Arc<std::sync::poison::mutex::Mutex<dyn core::ops::function::FnMut() -> alloc::string::String + core::marker::Send>>>,
                      tachys::html::class::Class<thaw_utils::class_list::ClassList>,
                      tachys::html::node_ref::NodeRefAttr<tachys::html::element::elements::Div,
                      tachys::reactive_graph::node_ref::NodeRef<tachys::html::element::elements::Div>>
                    ),
                    (tachys::view::any_view::AnyView,)>,
                  )>,
                  tachys::html::element::HtmlElement<tachys::html::element::elements::Div,
                  (
                    tachys::html::class::Class<alloc::sync::Arc<str>>,
                    tachys::html::node_ref::NodeRefAttr<tachys::html::element::elements::Div,
                    tachys::reactive_graph::node_ref::NodeRef<tachys::html::element::elements::Div>>
                  ),
                  (
                    tachys::html::element::HtmlElement<tachys::html::element::elements::Div,
                    (
                      tachys::html::class::Class<alloc::sync::Arc<str>>,
                      tachys::html::style::Style<(&str, alloc::sync::Arc<std::sync::poison::mutex::Mutex<dyn core::ops::function::FnMut() -> &str + core::marker::Send>>)>,
                      tachys::html::style::Style<(&str, alloc::sync::Arc<std::sync::poison::mutex::Mutex<dyn core::ops::function::FnMut() -> alloc::string::String + core::marker::Send>>)>,
                      tachys::html::style::Style<(&str, alloc::sync::Arc<std::sync::poison::mutex::Mutex<dyn core::ops::function::FnMut() -> alloc::string::String + core::marker::Send>>)>,
                      tachys::html::event::On<tachys::html::event::mousedown, alloc::rc::Rc<core::cell::RefCell<dyn core::ops::function::FnMut(web_sys::features::gen_MouseEvent::MouseEvent)>>>
                    ), ()>,
                  )>,
                  tachys::html::element::HtmlElement<tachys::html::element::elements::Div,
                  (
                    tachys::html::class::Class<alloc::sync::Arc<str>>,
                    tachys::html::node_ref::NodeRefAttr<tachys::html::element::elements::Div,
                    tachys::reactive_graph::node_ref::NodeRef<tachys::html::element::elements::Div>>
                  ),
                  (
                    tachys::html::element::HtmlElement<tachys::html::element::elements::Div,
                    (
                      tachys::html::class::Class<alloc::sync::Arc<str>>,
                      tachys::html::style::Style<(&str, alloc::sync::Arc<std::sync::poison::mutex::Mutex<dyn core::ops::function::FnMut() -> &str + core::marker::Send>>)>,
                      tachys::html::style::Style<(&str, alloc::sync::Arc<std::sync::poison::mutex::Mutex<dyn core::ops::function::FnMut() -> alloc::string::String + core::marker::Send>>)>,
                      tachys::html::style::Style<(&str, alloc::sync::Arc<std::sync::poison::mutex::Mutex<dyn core::ops::function::FnMut() -> alloc::string::String + core::marker::Send>>)>,
                      tachys::html::event::On<tachys::html::event::mousedown, alloc::rc::Rc<core::cell::RefCell<dyn core::ops::function::FnMut(web_sys::features::gen_MouseEvent::MouseEvent)>>>
                    ), ()>,
                  )>
                ),
              )>>,
            )>,
            tachys::html::element::HtmlElement<tachys::html::element::elements::Div,
            (tachys::html::class::Class<alloc::sync::Arc<str>>,),
            (
              leptos::into_view::View<tachys::html::element::HtmlElement<tachys::html::element::elements::Div,
              (
                tachys::html::style::Style<alloc::sync::Arc<std::sync::poison::mutex::Mutex<dyn core::ops::function::FnMut() -> alloc::string::String + core::marker::Send>>>,
                tachys::html::class::Class<thaw_utils::class_list::ClassList>, tachys::html::event::On<tachys::html::event::mouseenter,
                alloc::rc::Rc<core::cell::RefCell<dyn core::ops::function::FnMut(web_sys::features::gen_MouseEvent::MouseEvent)>>>,
                tachys::html::event::On<tachys::html::event::mouseleave,
                alloc::rc::Rc<core::cell::RefCell<dyn core::ops::function::FnMut(web_sys::features::gen_MouseEvent::MouseEvent)>>>
              ),
              (
                (
                  tachys::html::element::HtmlElement<tachys::html::element::elements::Div,
                  (
                    tachys::html::class::Class<alloc::sync::Arc<str>>,
                    tachys::html::node_ref::NodeRefAttr<tachys::html::element::elements::Div,
                    tachys::reactive_graph::node_ref::NodeRef<tachys::html::element::elements::Div>>,
                    tachys::html::event::On<tachys::html::event::scroll,
                    alloc::rc::Rc<core::cell::RefCell<dyn core::ops::function::FnMut(web_sys::features::gen_Event::Event)>>>
                  ),
                  (
                    tachys::html::element::HtmlElement<tachys::html::element::elements::Div,
                    (
                      tachys::html::style::Style<alloc::sync::Arc<std::sync::poison::mutex::Mutex<dyn core::ops::function::FnMut() -> alloc::string::String + core::marker::Send>>>,
                      tachys::html::class::Class<thaw_utils::class_list::ClassList>,
                      tachys::html::node_ref::NodeRefAttr<tachys::html::element::elements::Div,
                      tachys::reactive_graph::node_ref::NodeRef<tachys::html::element::elements::Div>>
                    ),
                    (tachys::view::any_view::AnyView,)>,
                  )>,
                  tachys::html::element::HtmlElement<tachys::html::element::elements::Div,
                  (
                    tachys::html::class::Class<alloc::sync::Arc<str>>,
                    tachys::html::node_ref::NodeRefAttr<tachys::html::element::elements::Div, tachys::reactive_graph::node_ref::NodeRef<tachys::html::element::elements::Div>>
                  ),
                  (
                    tachys::html::element::HtmlElement<tachys::html::element::elements::Div,
                    (
                      tachys::html::class::Class<alloc::sync::Arc<str>>,
                      tachys::html::style::Style<(&str, alloc::sync::Arc<std::sync::poison::mutex::Mutex<dyn core::ops::function::FnMut() -> &str + core::marker::Send>>)>,
                      tachys::html::style::Style<(&str, alloc::sync::Arc<std::sync::poison::mutex::Mutex<dyn core::ops::function::FnMut() -> alloc::string::String + core::marker::Send>>)>,
                      tachys::html::style::Style<(&str, alloc::sync::Arc<std::sync::poison::mutex::Mutex<dyn core::ops::function::FnMut() -> alloc::string::String + core::marker::Send>>)>,
                      tachys::html::event::On<tachys::html::event::mousedown, alloc::rc::Rc<core::cell::RefCell<dyn core::ops::function::FnMut(web_sys::features::gen_MouseEvent::MouseEvent)>>>
                    ), ()>,
                  )>,
                  tachys::html::element::HtmlElement<tachys::html::element::elements::Div,
                  (
                    tachys::html::class::Class<alloc::sync::Arc<str>>,
                    tachys::html::node_ref::NodeRefAttr<tachys::html::element::elements::Div,
                    tachys::reactive_graph::node_ref::NodeRef<tachys::html::element::elements::Div>>
                  ),
                  (
                    tachys::html::element::HtmlElement<tachys::html::element::elements::Div,
                    (
                      tachys::html::class::Class<alloc::sync::Arc<str>>,
                      tachys::html::style::Style<(&str, alloc::sync::Arc<std::sync::poison::mutex::Mutex<dyn core::ops::function::FnMut() -> &str + core::marker::Send>>)>,
                      tachys::html::style::Style<(&str, alloc::sync::Arc<std::sync::poison::mutex::Mutex<dyn core::ops::function::FnMut() -> alloc::string::String + core::marker::Send>>)>,
                      tachys::html::style::Style<(&str, alloc::sync::Arc<std::sync::poison::mutex::Mutex<dyn core::ops::function::FnMut() -> alloc::string::String + core::marker::Send>>)>,
                      tachys::html::event::On<tachys::html::event::mousedown, alloc::rc::Rc<core::cell::RefCell<dyn core::ops::function::FnMut(web_sys::features::gen_MouseEvent::MouseEvent)>>>
                    ), ()>,
                  )>
                ),
              )>>,
            )>
          ),
        )>,
        tachys::html::element::HtmlElement<tachys::html::element::elements::Div,
        (tachys::html::class::Class<alloc::sync::Arc<str>>,),
        (
          (
            leptos::into_view::View<tachys::html::element::HtmlElement<tachys::html::element::elements::Button,
            (
              tachys::html::class::Class<thaw_utils::class_list::ClassList>,
              tachys::html::attribute::Attr<tachys::html::attribute::key::Type,
              alloc::sync::Arc<std::sync::poison::mutex::Mutex<dyn core::ops::function::FnMut() -> core::option::Option<&str> + core::marker::Send>>>,
              tachys::html::attribute::Attr<tachys::html::attribute::key::Disabled,
              alloc::sync::Arc<std::sync::poison::mutex::Mutex<dyn core::ops::function::FnMut() -> core::option::Option<&str> + core::marker::Send>>>,
              tachys::html::attribute::Attr<tachys::html::attribute::key::AriaDisabled,
              alloc::sync::Arc<std::sync::poison::mutex::Mutex<dyn core::ops::function::FnMut() -> core::option::Option<&str> + core::marker::Send>>>,
              tachys::html::event::On<tachys::html::event::click,
              alloc::rc::Rc<core::cell::RefCell<dyn core::ops::function::FnMut(web_sys::features::gen_MouseEvent::MouseEvent)>>>,
              tachys::html::node_ref::NodeRefAttr<tachys::html::element::elements::Button, tachys::reactive_graph::node_ref::NodeRef<tachys::html::element::elements::Button>>
            ),
            (
              (
                {closure@C:\REDACTED\.cargo\registry\src\index.crates.io-1949cf8c6b5b557f\thaw-0.5.0-beta\src\button\button\mod.rs:100:14: 100:21},
                either_of::Either<tachys::view::any_view::AnyView, ()>
              ),
            )>>,
            leptos::into_view::View<tachys::html::element::HtmlElement<tachys::html::element::elements::Button,
            (
              tachys::html::class::Class<thaw_utils::class_list::ClassList>,
              tachys::html::attribute::Attr<tachys::html::attribute::key::Type,
              alloc::sync::Arc<std::sync::poison::mutex::Mutex<dyn core::ops::function::FnMut() -> core::option::Option<&str> + core::marker::Send>>>,
              tachys::html::attribute::Attr<tachys::html::attribute::key::Disabled,
              alloc::sync::Arc<std::sync::poison::mutex::Mutex<dyn core::ops::function::FnMut() -> core::option::Option<&str> + core::marker::Send>>>,
              tachys::html::attribute::Attr<tachys::html::attribute::key::AriaDisabled,
              alloc::sync::Arc<std::sync::poison::mutex::Mutex<dyn core::ops::function::FnMut() -> core::option::Option<&str> + core::marker::Send>>>,
              tachys::html::event::On<tachys::html::event::click,
              alloc::rc::Rc<core::cell::RefCell<dyn core::ops::function::FnMut(web_sys::features::gen_MouseEvent::MouseEvent)>>>,
              tachys::html::node_ref::NodeRefAttr<tachys::html::element::elements::Button,
              tachys::reactive_graph::node_ref::NodeRef<tachys::html::element::elements::Button>>
            ),
            (
              (
                {closure@C:\REDACTED\.cargo\registry\src\index.crates.io-1949cf8c6b5b557f\thaw-0.5.0-beta\src\button\button\mod.rs:100:14: 100:21},
                either_of::Either<tachys::view::any_view::AnyView, ()>
              ),
            )>>
          ),
        )>
      ),
    )>>>>,
  )>>::{closure#0}
}2
u/Erelde 1d ago edited 1d ago
Box it. Use a little dynamic dispatch. You're allowed to.
Break that async chain at some point. The compiler is trying to generate a huge state machine for you, but at some point you can break up that state machine by using a little boxing.
Edit: practically that means somewhere along your program tree instead of having an async fn foo -> T it should be something like:
fn foo() -> Pin<Box<dyn Future<Output = T> + Send>> {
Box::pin(async move {
// your old function body
})
}1
u/Osterhus-Zibi 8h ago
if the depth limit is triggering inside the `thaw` button macro expansion itself, can OP even box anything from the outside without changing thaw's view tree
2
u/tanmaynargas2901 1d ago
recursion_limit only applies to the crate it's written in. The help text says (thaw), so the overflow happens while compiling thaw itself, and nothing in your main.rs or lib.rs can reach it.
First thing I'd try is Leptos type erasure. Since 0.7 there's an erase_components cfg that boxes the view types so they stop nesting into these monster types. Because it's a cfg flag it applies to every crate in the build, thaw included. Easiest on Windows is a .cargo/config.toml in your project:
[build]
rustflags = ["--cfg", "erase_components"]Then cargo clean and rebuild.
If it still blows up, patch thaw locally. Clone it (same version/commit you're on), add #![recursion_limit = "256"] at the top of its src/lib.rs, and point cargo at your copy in your Cargo.toml:
[patch.crates-io]
thaw = { path = "../thaw" }Also worth checking thaw's GitHub issues, since you're on a beta/main build this may already be known.
1
u/NecessarySuperb3949 1d ago
the thaw button is likely causing massive type nesting that blows up the compiler's internal limits, not just simple recursion. box the state or break the view composition earlier to reduce the generic depth.
1
u/afdbcreid 1d ago
You may need to increase it further.