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

Server-side redirect causes error in Router with CSR #3425

Closed
spencewenski opened this issue Dec 31, 2024 · 0 comments
Closed

Server-side redirect causes error in Router with CSR #3425

spencewenski opened this issue Dec 31, 2024 · 0 comments

Comments

@spencewenski
Copy link
Contributor

spencewenski commented Dec 31, 2024

Describe the bug
Using a server-side redirect (e.g., leptos_axum::redirect("/foo") causes an error, but only in CSR mode. The error does not seem to occur when the same code is running in ssr/islands mode.

Error log:
panicked at /home/spencer/code/leptos/router/src/location/history.rs:252:24:
You cannot call `use_navigate` outside a <Router>.

Stack:

__wbg_get_imports/imports.wbg.__wbg_new_8a6f238a6ece86ea@http://localhost:3000/pkg/todo_app_sqlite_csr.js:824:13
todo_app_sqlite_csr.wasm.__wbg_new_8a6f238a6ece86ea externref shim@http://localhost:3000/pkg/todo_app_sqlite_csr.wasm:wasm-function[14588]:0x33e304
todo_app_sqlite_csr.wasm.console_error_panic_hook::Error::new::hbdbe0c8c77a26283@http://localhost:3000/pkg/todo_app_sqlite_csr.wasm:wasm-function[9366]:0x2f2e7f
todo_app_sqlite_csr.wasm.console_error_panic_hook::hook_impl::h83c3754cbce08587@http://localhost:3000/pkg/todo_app_sqlite_csr.wasm:wasm-function[2058]:0x1a955b
todo_app_sqlite_csr.wasm.console_error_panic_hook::hook::h40e5673863ed0a85@http://localhost:3000/pkg/todo_app_sqlite_csr.wasm:wasm-function[12968]:0x32d3d2
todo_app_sqlite_csr.wasm.core::ops::function::Fn::call::h97b0f7d99d260cf7@http://localhost:3000/pkg/todo_app_sqlite_csr.wasm:wasm-function[11146]:0x313c5e
todo_app_sqlite_csr.wasm.std::panicking::rust_panic_with_hook::heb1fa7c95b92daf7@http://localhost:3000/pkg/todo_app_sqlite_csr.wasm:wasm-function[4991]:0x26a90a
todo_app_sqlite_csr.wasm.std::panicking::begin_panic_handler::{{closure}}::h3c2bc8468c50b1ce@http://localhost:3000/pkg/todo_app_sqlite_csr.wasm:wasm-function[6011]:0x295ce4
todo_app_sqlite_csr.wasm.std::sys::backtrace::__rust_end_short_backtrace::h8e8868764214f28d@http://localhost:3000/pkg/todo_app_sqlite_csr.wasm:wasm-function[14840]:0x33f08c
todo_app_sqlite_csr.wasm.rust_begin_unwind@http://localhost:3000/pkg/todo_app_sqlite_csr.wasm:wasm-function[13891]:0x338be6
todo_app_sqlite_csr.wasm.core::panicking::panic_fmt::h067fb97c138f603d@http://localhost:3000/pkg/todo_app_sqlite_csr.wasm:wasm-function[13892]:0x338c12
todo_app_sqlite_csr.wasm.core::option::expect_failed::h2103969ebc242f3f@http://localhost:3000/pkg/todo_app_sqlite_csr.wasm:wasm-function[9018]:0x2eb7b8
todo_app_sqlite_csr.wasm.core::option::Option<T>::expect::h3f4a2849e3b7d6db@http://localhost:3000/pkg/todo_app_sqlite_csr.wasm:wasm-function[6352]:0x2a2063
todo_app_sqlite_csr.wasm.leptos_router::hooks::use_navigate::h89345b0214e41109@http://localhost:3000/pkg/todo_app_sqlite_csr.wasm:wasm-function[7074]:0x2b8e19
todo_app_sqlite_csr.wasm.<leptos_router::location::history::BrowserUrl as leptos_router::location::LocationProvider>::redirect::hb9eb910c03515e0b@http://localhost:3000/pkg/todo_app_sqlite_csr.wasm:wasm-function[233]:0x482ac
todo_app_sqlite_csr.wasm.leptos_router::components::__Router::{{closure}}::h17915be0486cff09@http://localhost:3000/pkg/todo_app_sqlite_csr.wasm:wasm-function[10998]:0x3114f7
todo_app_sqlite_csr.wasm.<alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h83682b682115b120@http://localhost:3000/pkg/todo_app_sqlite_csr.wasm:wasm-function[9104]:0x2ed59a
todo_app_sqlite_csr.wasm.<alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h0adde0923059c732@http://localhost:3000/pkg/todo_app_sqlite_csr.wasm:wasm-function[8087]:0x2d50d2
todo_app_sqlite_csr.wasm.server_fn::ServerFn::run_on_client_with_req::{{closure}}::hb08fd0b96af7e1b1@http://localhost:3000/pkg/todo_app_sqlite_csr.wasm:wasm-function[189]:0x24249
todo_app_sqlite_csr.wasm.server_fn::ServerFn::run_on_client::{{closure}}::hd2ef35c728a972e9@http://localhost:3000/pkg/todo_app_sqlite_csr.wasm:wasm-function[507]:0xbbd7a
todo_app_sqlite_csr.wasm.<core::pin::Pin<P> as core::future::future::Future>::poll::h775ae5b9893e00dc@http://localhost:3000/pkg/todo_app_sqlite_csr.wasm:wasm-function[7764]:0x2cc8b2
todo_app_sqlite_csr.wasm.reactive_graph::actions::multi_action::ArcMultiAction<I,O>::dispatch::{{closure}}::h8296a8f3b94dc098@http://localhost:3000/pkg/todo_app_sqlite_csr.wasm:wasm-function[434]:0xa52c4
todo_app_sqlite_csr.wasm.<core::pin::Pin<P> as core::future::future::Future>::poll::h499bd45cc96f4591@http://localhost:3000/pkg/todo_app_sqlite_csr.wasm:wasm-function[6922]:0x2b45b1
todo_app_sqlite_csr.wasm.wasm_bindgen_futures::task::singlethread::Task::run::h5bda0f545c603dc0@http://localhost:3000/pkg/todo_app_sqlite_csr.wasm:wasm-function[1365]:0x159ecc
todo_app_sqlite_csr.wasm.wasm_bindgen_futures::queue::QueueState::run_all::hdc3531af6c567f4c@http://localhost:3000/pkg/todo_app_sqlite_csr.wasm:wasm-function[1005]:0x1258ff
todo_app_sqlite_csr.wasm.wasm_bindgen_futures::queue::Queue::new::{{closure}}::h8e8a8e88296c4cf4@http://localhost:3000/pkg/todo_app_sqlite_csr.wasm:wasm-function[6924]:0x2b46a8
todo_app_sqlite_csr.wasm.<dyn core::ops::function::FnMut<(A,)>+Output = R as wasm_bindgen::closure::WasmClosure>::describe::invoke::h26c654581897192c@http://localhost:3000/pkg/todo_app_sqlite_csr.wasm:wasm-function[5245]:0x27618d
todo_app_sqlite_csr.wasm.closure878 externref shim@http://localhost:3000/pkg/todo_app_sqlite_csr.wasm:wasm-function[14568]:0x33e16f
__wbg_adapter_48@http://localhost:3000/pkg/todo_app_sqlite_csr.js:244:6
real@http://localhost:3000/pkg/todo_app_sqlite_csr.js:121:32
VoidFunction*__wbg_get_imports/imports.wbg.__wbg_queueMicrotask_2181040e064c0dc8@http://localhost:3000/pkg/todo_app_sqlite_csr.js:910:15
todo_app_sqlite_csr.wasm.__wbg_queueMicrotask_2181040e064c0dc8 externref shim@http://localhost:3000/pkg/todo_app_sqlite_csr.wasm:wasm-function[14882]:0x33f20a
todo_app_sqlite_csr.wasm.wasm_bindgen_futures::queue::queueMicrotask::h8bcf60743442080d@http://localhost:3000/pkg/todo_app_sqlite_csr.wasm:wasm-function[10088]:0x3016ee
todo_app_sqlite_csr.wasm.wasm_bindgen_futures::queue::Queue::schedule_task::hecb8471aeba43914@http://localhost:3000/pkg/todo_app_sqlite_csr.wasm:wasm-function[2082]:0x1abcd6
todo_app_sqlite_csr.wasm.wasm_bindgen_futures::queue::Queue::push_task::h6f84215f42da71a7@http://localhost:3000/pkg/todo_app_sqlite_csr.wasm:wasm-function[11681]:0x31c106
todo_app_sqlite_csr.wasm.wasm_bindgen_futures::task::singlethread::Task::force_wake::{{closure}}::h1aea366d6b2aa493@http://localhost:3000/pkg/todo_app_sqlite_csr.wasm:wasm-function[11679]:0x31c08d
todo_app_sqlite_csr.wasm.std::thread::local::LocalKey<T>::try_with::hff43ed7627565dcf@http://localhost:3000/pkg/todo_app_sqlite_csr.wasm:wasm-function[3616]:0x21f979
todo_app_sqlite_csr.wasm.std::thread::local::LocalKey<T>::with::h5812eab7f00e6ff5@http://localhost:3000/pkg/todo_app_sqlite_csr.wasm:wasm-function[5320]:0x27962e
todo_app_sqlite_csr.wasm.wasm_bindgen_futures::queue::Queue::with::h229542ac0c9e2422@http://localhost:3000/pkg/todo_app_sqlite_csr.wasm:wasm-function[11823]:0x31e24e
todo_app_sqlite_csr.wasm.wasm_bindgen_futures::task::singlethread::Task::force_wake::he2d881c110cb4d46@http://localhost:3000/pkg/todo_app_sqlite_csr.wasm:wasm-function[13453]:0x33368d
todo_app_sqlite_csr.wasm.wasm_bindgen_futures::task::singlethread::Task::wake::haba4ace0f33f925c@http://localhost:3000/pkg/todo_app_sqlite_csr.wasm:wasm-function[4321]:0x248ec3
todo_app_sqlite_csr.wasm.wasm_bindgen_futures::task::singlethread::Task::into_raw_waker::raw_wake::h8daf83cc403aac2a@http://localhost:3000/pkg/todo_app_sqlite_csr.wasm:wasm-function[11349]:0x316f89
todo_app_sqlite_csr.wasm.core::task::wake::Waker::wake::h6f934f424a689711@http://localhost:3000/pkg/todo_app_sqlite_csr.wasm:wasm-function[6852]:0x2b2394
todo_app_sqlite_csr.wasm.<wasm_bindgen_futures::JsFuture as core::convert::From<js_sys::Promise>>::from::finish::h6ada07cd9de08bca@http://localhost:3000/pkg/todo_app_sqlite_csr.wasm:wasm-function[856]:0x10bb5f
todo_app_sqlite_csr.wasm.<wasm_bindgen_futures::JsFuture as core::convert::From<js_sys::Promise>>::from::{{closure}}::ha95ceb60bddfeaf5@http://localhost:3000/pkg/todo_app_sqlite_csr.wasm:wasm-function[6375]:0x2a2ce1
todo_app_sqlite_csr.wasm.core::ops::function::FnOnce::call_once::hbd106f504c6364de@http://localhost:3000/pkg/todo_app_sqlite_csr.wasm:wasm-function[7984]:0x2d2676
todo_app_sqlite_csr.wasm.<T as wasm_bindgen::closure::WasmClosureFnOnce<A,R>>::into_fn_mut::{{closure}}::h4f7cd33109f3604b@http://localhost:3000/pkg/todo_app_sqlite_csr.wasm:wasm-function[8578]:0x2e144a
todo_app_sqlite_csr.wasm.<dyn core::ops::function::FnMut<(A,)>+Output = R as wasm_bindgen::closure::WasmClosure>::describe::invoke::h26c654581897192c@http://localhost:3000/pkg/todo_app_sqlite_csr.wasm:wasm-function[5245]:0x27618d
todo_app_sqlite_csr.wasm.closure878 externref shim@http://localhost:3000/pkg/todo_app_sqlite_csr.wasm:wasm-function[14568]:0x33e16f
__wbg_adapter_48@http://localhost:3000/pkg/todo_app_sqlite_csr.js:244:6
real@http://localhost:3000/pkg/todo_app_sqlite_csr.js:121:32
promise callback*__wbg_get_imports/imports.wbg.__wbg_then_0ffafeddf0e182a4@http://localhost:3000/pkg/todo_app_sqlite_csr.js:1062:18
todo_app_sqlite_csr.wasm.__wbg_then_0ffafeddf0e182a4 externref shim@http://localhost:3000/pkg/todo_app_sqlite_csr.wasm:wasm-function[14376]:0x33ce01
todo_app_sqlite_csr.wasm.js_sys::Promise::then2::h3010f1f26b1ba304@http://localhost:3000/pkg/todo_app_sqlite_csr.wasm:wasm-function[5038]:0x26cbfe
todo_app_sqlite_csr.wasm.<wasm_bindgen_futures::JsFuture as core::convert::From<js_sys::Promise>>::from::h7f25f6dbaf5847ab@http://localhost:3000/pkg/todo_app_sqlite_csr.wasm:wasm-function[488]:0xb63ff
todo_app_sqlite_csr.wasm.gloo_net::http::response::Response::text::{{closure}}::h163d0d5bd486276c@http://localhost:3000/pkg/todo_app_sqlite_csr.wasm:wasm-function[403]:0x9a57b
todo_app_sqlite_csr.wasm.<server_fn::response::browser::BrowserResponse as server_fn::response::ClientRes<CustErr>>::try_into_string::{{closure}}::hac97427a65570970@http://localhost:3000/pkg/todo_app_sqlite_csr.wasm:wasm-function[735]:0xf373d
todo_app_sqlite_csr.wasm.send_wrapper::futures::<impl core::future::future::Future for send_wrapper::SendWrapper<F>>::poll::h141fa6df34e5579a@http://localhost:3000/pkg/todo_app_sqlite_csr.wasm:wasm-function[7934]:0x2d1190
todo_app_sqlite_csr.wasm.server_fn::codec::json::<impl server_fn::codec::FromRes<server_fn::codec::json::Json,Response,CustErr> for T>::from_res::{{closure}}::hdbbfcbf2b80b7afb@http://localhost:3000/pkg/todo_app_sqlite_csr.wasm:wasm-function[447]:0xa993b
todo_app_sqlite_csr.wasm.server_fn::ServerFn::run_on_client_with_req::{{closure}}::hb08fd0b96af7e1b1@http://localhost:3000/pkg/todo_app_sqlite_csr.wasm:wasm-function[189]:0x23a28
todo_app_sqlite_csr.wasm.server_fn::ServerFn::run_on_client::{{closure}}::hd2ef35c728a972e9@http://localhost:3000/pkg/todo_app_sqlite_csr.wasm:wasm-function[507]:0xbbd7a
todo_app_sqlite_csr.wasm.<core::pin::Pin<P> as core::future::future::Future>::poll::h775ae5b9893e00dc@http://localhost:3000/pkg/todo_app_sqlite_csr.wasm:wasm-function[7764]:0x2cc8b2
todo_app_sqlite_csr.wasm.reactive_graph::actions::multi_action::ArcMultiAction<I,O>::dispatch::{{closure}}::h8296a8f3b94dc098@http://localhost:3000/pkg/todo_app_sqlite_csr.wasm:wasm-function[434]:0xa52c4
todo_app_sqlite_csr.wasm.<core::pin::Pin<P> as core::future::future::Future>::poll::h499bd45cc96f4591@http://localhost:3000/pkg/todo_app_sqlite_csr.wasm:wasm-function[6922]:0x2b45b1
todo_app_sqlite_csr.wasm.wasm_bindgen_futures::task::singlethread::Task::run::h5bda0f545c603dc0@http://localhost:3000/pkg/todo_app_sqlite_csr.wasm:wasm-function[1365]:0x159ecc
todo_app_sqlite_csr.wasm.wasm_bindgen_futures::queue::QueueState::run_all::hdc3531af6c567f4c@http://localhost:3000/pkg/todo_app_sqlite_csr.wasm:wasm-function[1005]:0x1258ff
todo_app_sqlite_csr.wasm.wasm_bindgen_futures::queue::Queue::new::{{closure}}::h8e8a8e88296c4cf4@http://localhost:3000/pkg/todo_app_sqlite_csr.wasm:wasm-function[6924]:0x2b46a8
todo_app_sqlite_csr.wasm.<dyn core::ops::function::FnMut<(A,)>+Output = R as wasm_bindgen::closure::WasmClosure>::describe::invoke::h26c654581897192c@http://localhost:3000/pkg/todo_app_sqlite_csr.wasm:wasm-function[5245]:0x27618d
todo_app_sqlite_csr.wasm.closure878 externref shim@http://localhost:3000/pkg/todo_app_sqlite_csr.wasm:wasm-function[14568]:0x33e16f
__wbg_adapter_48@http://localhost:3000/pkg/todo_app_sqlite_csr.js:244:6
real@http://localhost:3000/pkg/todo_app_sqlite_csr.js:121:32
VoidFunction*__wbg_get_imports/imports.wbg.__wbg_queueMicrotask_2181040e064c0dc8@http://localhost:3000/pkg/todo_app_sqlite_csr.js:910:15
todo_app_sqlite_csr.wasm.__wbg_queueMicrotask_2181040e064c0dc8 externref shim@http://localhost:3000/pkg/todo_app_sqlite_csr.wasm:wasm-function[14882]:0x33f20a
todo_app_sqlite_csr.wasm.wasm_bindgen_futures::queue::queueMicrotask::h8bcf60743442080d@http://localhost:3000/pkg/todo_app_sqlite_csr.wasm:wasm-function[10088]:0x3016ee
todo_app_sqlite_csr.wasm.wasm_bindgen_futures::queue::Queue::schedule_task::hecb8471aeba43914@http://localhost:3000/pkg/todo_app_sqlite_csr.wasm:wasm-function[2082]:0x1abcd6
todo_app_sqlite_csr.wasm.wasm_bindgen_futures::queue::Queue::push_task::h6f84215f42da71a7@http://localhost:3000/pkg/todo_app_sqlite_csr.wasm:wasm-function[11681]:0x31c106
todo_app_sqlite_csr.wasm.wasm_bindgen_futures::task::singlethread::Task::force_wake::{{closure}}::h1aea366d6b2aa493@http://localhost:3000/pkg/todo_app_sqlite_csr.wasm:wasm-function[11679]:0x31c08d
todo_app_sqlite_csr.wasm.std::thread::local::LocalKey<T>::try_with::hff43ed7627565dcf@http://localhost:3000/pkg/todo_app_sqlite_csr.wasm:wasm-function[3616]:0x21f979
todo_app_sqlite_csr.wasm.std::thread::local::LocalKey<T>::with::h5812eab7f00e6ff5@http://localhost:3000/pkg/todo_app_sqlite_csr.wasm:wasm-function[5320]:0x27962e
todo_app_sqlite_csr.wasm.wasm_bindgen_futures::queue::Queue::with::h229542ac0c9e2422@http://localhost:3000/pkg/todo_app_sqlite_csr.wasm:wasm-function[11823]:0x31e24e
todo_app_sqlite_csr.wasm.wasm_bindgen_futures::task::singlethread::Task::force_wake::he2d881c110cb4d46@http://localhost:3000/pkg/todo_app_sqlite_csr.wasm:wasm-function[13453]:0x33368d
todo_app_sqlite_csr.wasm.wasm_bindgen_futures::task::singlethread::Task::wake::haba4ace0f33f925c@http://localhost:3000/pkg/todo_app_sqlite_csr.wasm:wasm-function[4321]:0x248ec3
todo_app_sqlite_csr.wasm.wasm_bindgen_futures::task::singlethread::Task::into_raw_waker::raw_wake::h8daf83cc403aac2a@http://localhost:3000/pkg/todo_app_sqlite_csr.wasm:wasm-function[11349]:0x316f89
todo_app_sqlite_csr.wasm.core::task::wake::Waker::wake::h6f934f424a689711@http://localhost:3000/pkg/todo_app_sqlite_csr.wasm:wasm-function[6852]:0x2b2394
todo_app_sqlite_csr.wasm.<wasm_bindgen_futures::JsFuture as core::convert::From<js_sys::Promise>>::from::finish::h6ada07cd9de08bca@http://localhost:3000/pkg/todo_app_sqlite_csr.wasm:wasm-function[856]:0x10bb5f
todo_app_sqlite_csr.wasm.<wasm_bindgen_futures::JsFuture as core::convert::From<js_sys::Promise>>::from::{{closure}}::ha95ceb60bddfeaf5@http://localhost:3000/pkg/todo_app_sqlite_csr.wasm:wasm-function[6375]:0x2a2ce1
todo_app_sqlite_csr.wasm.core::ops::function::FnOnce::call_once::hbd106f504c6364de@http://localhost:3000/pkg/todo_app_sqlite_csr.wasm:wasm-function[7984]:0x2d2676
todo_app_sqlite_csr.wasm.<T as wasm_bindgen::closure::WasmClosureFnOnce<A,R>>::into_fn_mut::{{closure}}::h4f7cd33109f3604b@http://localhost:3000/pkg/todo_app_sqlite_csr.wasm:wasm-function[8578]:0x2e144a
todo_app_sqlite_csr.wasm.<dyn core::ops::function::FnMut<(A,)>+Output = R as wasm_bindgen::closure::WasmClosure>::describe::invoke::h26c654581897192c@http://localhost:3000/pkg/todo_app_sqlite_csr.wasm:wasm-function[5245]:0x27618d
todo_app_sqlite_csr.wasm.closure878 externref shim@http://localhost:3000/pkg/todo_app_sqlite_csr.wasm:wasm-function[14568]:0x33e16f
__wbg_adapter_48@http://localhost:3000/pkg/todo_app_sqlite_csr.js:244:6
real@http://localhost:3000/pkg/todo_app_sqlite_csr.js:121:32
promise callback*__wbg_get_imports/imports.wbg.__wbg_then_0ffafeddf0e182a4@http://localhost:3000/pkg/todo_app_sqlite_csr.js:1062:18
todo_app_sqlite_csr.wasm.__wbg_then_0ffafeddf0e182a4 externref shim@http://localhost:3000/pkg/todo_app_sqlite_csr.wasm:wasm-function[14376]:0x33ce01
todo_app_sqlite_csr.wasm.js_sys::Promise::then2::h3010f1f26b1ba304@http://localhost:3000/pkg/todo_app_sqlite_csr.wasm:wasm-function[5038]:0x26cbfe
todo_app_sqlite_csr.wasm.<wasm_bindgen_futures::JsFuture as core::convert::From<js_sys::Promise>>::from::h7f25f6dbaf5847ab@http://localhost:3000/pkg/todo_app_sqlite_csr.wasm:wasm-function[488]:0xb63ff
todo_app_sqlite_csr.wasm.gloo_net::http::request::Request::send::{{closure}}::hef1dad6722eb3458@http://localhost:3000/pkg/todo_app_sqlite_csr.wasm:wasm-function[448]:0xa9d01
todo_app_sqlite_csr.wasm.<server_fn::client::browser::BrowserClient as server_fn::client::Client<CustErr>>::send::{{closure}}::hc6ea1dc13bcab29d@http://localhost:3000/pkg/todo_app_sqlite_csr.wasm:wasm-function[452]:0xab337
todo_app_sqlite_csr.wasm.send_wrapper::futures::<impl core::future::future::Future for send_wrapper::SendWrapper<F>>::poll::hc8fdc4210bd6ffff@http://localhost:3000/pkg/todo_app_sqlite_csr.wasm:wasm-function[7938]:0x2d1338
todo_app_sqlite_csr.wasm.server_fn::ServerFn::run_on_client_with_req::{{closure}}::hb08fd0b96af7e1b1@http://localhost:3000/pkg/todo_app_sqlite_csr.wasm:wasm-function[189]:0x23322
todo_app_sqlite_csr.wasm.server_fn::ServerFn::run_on_client::{{closure}}::hd2ef35c728a972e9@http://localhost:3000/pkg/todo_app_sqlite_csr.wasm:wasm-function[507]:0xbbd7a
todo_app_sqlite_csr.wasm.<core::pin::Pin<P> as core::future::future::Future>::poll::h775ae5b9893e00dc@http://localhost:3000/pkg/todo_app_sqlite_csr.wasm:wasm-function[7764]:0x2cc8b2
todo_app_sqlite_csr.wasm.reactive_graph::actions::multi_action::ArcMultiAction<I,O>::dispatch::{{closure}}::h8296a8f3b94dc098@http://localhost:3000/pkg/todo_app_sqlite_csr.wasm:wasm-function[434]:0xa52c4
todo_app_sqlite_csr.wasm.<core::pin::Pin<P> as core::future::future::Future>::poll::h499bd45cc96f4591@http://localhost:3000/pkg/todo_app_sqlite_csr.wasm:wasm-function[6922]:0x2b45b1
todo_app_sqlite_csr.wasm.wasm_bindgen_futures::task::singlethread::Task::run::h5bda0f545c603dc0@http://localhost:3000/pkg/todo_app_sqlite_csr.wasm:wasm-function[1365]:0x159ecc
todo_app_sqlite_csr.wasm.wasm_bindgen_futures::queue::QueueState::run_all::hdc3531af6c567f4c@http://localhost:3000/pkg/todo_app_sqlite_csr.wasm:wasm-function[1005]:0x1258ff
todo_app_sqlite_csr.wasm.wasm_bindgen_futures::queue::Queue::new::{{closure}}::h8e8a8e88296c4cf4@http://localhost:3000/pkg/todo_app_sqlite_csr.wasm:wasm-function[6924]:0x2b46a8
todo_app_sqlite_csr.wasm.<dyn core::ops::function::FnMut<(A,)>+Output = R as wasm_bindgen::closure::WasmClosure>::describe::invoke::h26c654581897192c@http://localhost:3000/pkg/todo_app_sqlite_csr.wasm:wasm-function[5245]:0x27618d
todo_app_sqlite_csr.wasm.closure878 externref shim@http://localhost:3000/pkg/todo_app_sqlite_csr.wasm:wasm-function[14568]:0x33e16f
__wbg_adapter_48@http://localhost:3000/pkg/todo_app_sqlite_csr.js:244:6
real@http://localhost:3000/pkg/todo_app_sqlite_csr.js:121:32


todo_app_sqlite_csr.js:556:9

Example repro code:
#[server]
pub async fn delete_todo(id: u16) -> Result<(), ServerFnError> {
    use self::ssr::*;
    let mut conn = db().await?;

    leptos_axum::redirect("/foo");

    Ok(sqlx::query("DELETE FROM todos WHERE id = $1")
        .bind(id)
        .execute(&mut conn)
        .await
        .map(|_| ())?)
}

#[component]
pub fn TodoApp() -> impl IntoView {
    view! {
        <header>
            <h1>"My Tasks"</h1>
        </header>
        <main>
            <Router>
                <Routes fallback=|| "Not found">
                    <Route path=path!("/") view=Todos />
                    <Route path=path!("/foo") view=Foo />
                </Routes>
            </Router>
        </main>
    }
}

#[component]
fn Foo() -> impl IntoView {
    view! {
        <p>"Foo"</p>
    }
}

To Reproduce
Steps to reproduce the behavior:

  1. Run the todo_app_sqlite_csr example from: spencewenski@030530f
  2. Open the dev console
  3. Click on one of the delete buttons
  4. See error

Expected behavior
The app should route to /foo (due to the server-side redirect to /foo).

Additional context
For context, I started building my app with ssr/islands, but I also want to support CSR mode in the same core app code so I can use Leptos for both a website (with ssr/islands) and a Tauri app (with CSR).

spencewenski added a commit to spencewenski/leptos that referenced this issue Dec 31, 2024
spencewenski added a commit to spencewenski/leptos that referenced this issue Dec 31, 2024
@gbj gbj closed this as completed in 46f6d9a Dec 31, 2024
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