Closed tqwewe closed 1 year ago
It seems like it really is just too much HTML causing this. If you comment out single thing really, then it works
Aditionally, when I try to add even more HTML, I get this error:
❯ cargo leptos watch
Compiling leptos_start v0.1.0 (/Users/ari/dev/thalo-rs/thalo-web-leptos)
Finished dev [unoptimized + debuginfo] target(s) in 2m 23s
Cargo finished cargo build --package=leptos_start --lib --target-dir=target/front --target=wasm32-unknown-unknown --no-default-features --features=hydrate
Error: at `/Users/ari/.cargo/registry/src/github.com-1ecc6299db9ec823/cargo-leptos-0.1.3/src/compile/front.rs:40:30`
Caused by:
0: at `/Users/ari/.cargo/registry/src/github.com-1ecc6299db9ec823/cargo-leptos-0.1.3/src/compile/front.rs:107:10`
1: failed getting Wasm module for 'target/front/wasm32-unknown-unknown/debug/leptos_start.wasm'
2: failed to parse input as wasm
3: failed to parse code section
4: locals exceed maximum (at offset 899821)
If you break some of that out into separate components, does it resolve the issue or does it still overflow?
@gbj it seems like moving it into a separate function/component still results in the error, regardless of if the separated component is in another file, or the same file.
A temporary solution for this specific error is to set the env var RUST_MIN_STACK = "33554432"
. But after doing this, I get the other locals exceed maximum
error as mentioned before.
Edit:
To fix the locals exceed maximum
error, you can add:
[profile.dev]
opt-level = 1
incremental = true
To your cargo.toml to solve this, as it optimizes away a lot of the local variables created by the view!
macro.
Okay, thanks. This optimization is interesting! A few contributors and I were discussing this in the Discord and it's pretty clear what's happening here, although it would mean a deopt for SSR in general to fix it, which is sad. Basically we use SmallVec
to avoid heap allocations when the numbers of attributes/children are small; because you have a fairly large number of very small elements, in never allocates on the heap (yay!) but instead overflows the stack (boo!) while trying to render.
It looks like increasing the stack size will at least unblock you for now. The longer-term solution is an optimization to SSR for the view macro that I'm working on reintroducing that would basically convert your entire component there into a single static HTML string. So I think I'll leave this open for now, not switch away from SmallVec
, and keep working on the SSR optimization as the actual solution.
I created a new leptos project, and added some HTML, and stragely I get this error:
It seems like its when I have too much HTML for some reason?
The
<li></li>
here causes the error, and when you comment it out, the error goes away.View full
```rust use leptos::*; use leptos_meta::*; use leptos_router::*; #[component] pub fn App(cx: Scope) -> impl IntoView { // Provides context that manages stylesheets, titles, meta tags, etc. provide_meta_context(cx); view! { cx, // injects a stylesheet into the document // id=leptos means cargo-leptos will hot-reload this stylesheetapp.rs
file// vvvvvv Try commenting this li out, and the error goes away
"Favorites"
"Group 1"
"Welcome to Leptos!"
// } } ```Edit:
The simple fix in my case was:
RUST_MIN_STACK
to a higher value (eg:"33554432"
)Cargo.toml