leptos-struct-table icon indicating copy to clipboard operation
leptos-struct-table copied to clipboard

Panic on client side render with leptos-0.7. Reading beyond the size of the vector.

Open cramhead opened this issue 10 months ago • 3 comments

Using the leptos-0.7 branch with a leptos 0.7.7, I get a panic when rendering the leptos-struct-table. With the code below I get a panic when I attempt to display the component. I'm quite new to Rust so I'm not sure what's happening. I'm expecting that iteration of the 9 rows is not stopping and the table tries to read further than it should.

Image
use leptos::prelude::*;
use leptos_struct_table::*;

#[derive(TableRow, Clone)]
#[table(sortable, impl_vec_data_provider)]
pub struct Crate {
    name: String,
    url: String,
}

#[component]
pub fn OpenSourceCrates() -> impl IntoView {
    let rows = vec![
        Crate {
            url: "https://crates.io/crates/leptos".to_string(),
            name: "Leptos".to_string(),
        },
        Crate {
            url: "https://crates.io/crates/leptos_router".to_string(),
            name: "Leptos Router".to_string(),
        },
        Crate {
            url: "https://crates.io/crates/leptos_meta".to_string(),
            name: "Leptos Meta".to_string(),
        },
        Crate {
            url: "https://crates.io/crates/axum".to_string(),
            name: "Axum".to_string(),
        },
        Crate {
            url: "https://crates.io/crates/tokio".to_string(),
            name: "Tokio".to_string(),
        },
        Crate {
            url: "https://crates.io/crates/console_error_panic_hook".to_string(),
            name: "console_error_panic_hook".to_string(),
        },
        Crate {
            url: "https://crates.io/crates/wasm-bindgen".to_string(),
            name: "wasm-bindgen".to_string(),
        },
        Crate {
            url: "https://crates.io/crates/leptos-axum".to_string(),
            name: "leptos-axum".to_string(),
        },
        Crate {
            url: "https://crates.io/crates/leptos-struct-table".to_string(),
            name: "leptos-struct-table".to_string(),
        },
    ];
    view! {
        <table>
            <TableContent rows=rows scroll_container="html" />
        </table>
    }
}

cramhead avatar Feb 28 '25 02:02 cramhead

Can you try with the latest beta version?

leptos-struct-table = "0.14.0-beta2"

maccesch avatar Feb 28 '25 05:02 maccesch

I was able to try version 0.14.0-beta2, but unfortunately I got the same error.

cramhead avatar Mar 03 '25 21:03 cramhead

I've had some success! After cloning the leptos-struct-table-macro and using a local repo on the master branch I can now render the leptos-struct-table with no errors. I'm guessing the 0.14.0-beta2 version is missing something.

I double checked by switching back to the 0.14.0-beta2 version and the error reappeared

Image

I did a cursory investigation of the source to see if I could spot anything, but nothing stood out. I guess that could be because the issue is not there on master, but is on the deployed beta.

cramhead avatar Mar 04 '25 01:03 cramhead