leptos-rs / leptos

Build fast web applications with Rust.
https://leptos.dev
MIT License
15.31k stars 599 forks source link

Minor: examples/server_fns_axum FileWatcher logs errors to the console. #2547

Closed martinfrances107 closed 2 months ago

martinfrances107 commented 2 months ago

The cause is an assumption that the directory

./watched_files/

exits.

Thankfully the fix is simple

git has a standard convention - for preserving an empty directory. Insert a zero sized file named EMPTY.

Here is the error -- logged to the browsers console.

[HOT RELOADING] Connected to server.
:3000/api/watched_files13867909705750298573:1 

Failed to load resource: the server responded with a status of 500 (Internal Server Error)
server_fns_axum.js:503 panicked at src/app.rs:598:39:
called `Result::unwrap()` on an `Err` value: ServerError("No such file or directory (os error 2)")

Stack:

Error
    at imports.wbg.__wbg_new_abda76e883ba8a5f (http://127.0.0.1:3000/pkg/server_fns_axum.js:506:13)
    at console_error_panic_hook::Error::new::hca6973c430994da6 (http://127.0.0.1:3000/pkg/server_fns_axum.wasm:wasm-function[14183]:0x7c21d5)
    at console_error_panic_hook::hook_impl::hb822a00a5f8799dc (http://127.0.0.1:3000/pkg/server_fns_axum.wasm:wasm-function[3949]:0x5ebf84)
    at console_error_panic_hook::hook::h2fb62dcdff77287b (http://127.0.0.1:3000/pkg/server_fns_axum.wasm:wasm-function[16805]:0x7eb1aa)
    at core::ops::function::Fn::call::ha0f32b73068dce3a (http://127.0.0.1:3000/pkg/server_fns_axum.wasm:wasm-function[15300]:0x7d560b)
    at std::panicking::rust_panic_with_hook::h9aabd906218897c3 (http://127.0.0.1:3000/pkg/server_fns_axum.wasm:wasm-function[7470]:0x6ee2ab)
    at std::panicking::begin_panic_handler::{{closure}}::h96d2bc381fa6ee1e (http://127.0.0.1:3000/pkg/server_fns_axum.wasm:wasm-function[9088]:0x73a22f)
    at std::sys_common::backtrace::__rust_end_short_backtrace::ha76513a70bb070b0 (http://127.0.0.1:3000/pkg/server_fns_axum.wasm:wasm-function[19698]:0x8073cc)
    at rust_begin_unwind (http://127.0.0.1:3000/pkg/server_fns_axum.wasm:wasm-function[15919]:0x7df06b)
    at core::panicking::panic_fmt::h3aff855fe938c13f (http://127.0.0.1:3000/pkg/server_fns_axum.wasm:wasm-function[16578]:0x7e82f1)

imports.wbg.__wbg_error_f851667af71bcfc6 @ server_fns_axum.js:503
server_fns_axum.wasm:0x807675 Uncaught RuntimeError: unreachable
    at __rust_start_panic (server_fns_axum.wasm:0x807675)
    at rust_panic (server_fns_axum.wasm:0x806e01)
    at std::panicking::rust_panic_with_hook::h9aabd906218897c3 (server_fns_axum.wasm:0x6ee2d8)
    at std::panicking::begin_panic_handler::{{closure}}::h96d2bc381fa6ee1e (server_fns_axum.wasm:0x73a22f)
    at std::sys_common::backtrace::__rust_end_short_backtrace::ha76513a70bb070b0 (server_fns_axum.wasm:0x8073cc)
    at rust_begin_unwind (server_fns_axum.wasm:0x7df06b)
    at core::panicking::panic_fmt::h3aff855fe938c13f (server_fns_axum.wasm:0x7e82f1)
    at core::result::unwrap_failed::had70491c62ee681b (server_fns_axum.wasm:0x762916)
    at server_fns_axum::app::__FileWatcher::{{closure}}::{{closure}}::h6e2dc10b43754c36 (server_fns_axum.wasm:0xe23c9)
    at wasm_bindgen_futures::task::singlethread::Task::run::h9ad08afc33b86ae6 (server_fns_axum.wasm:0x579590)
mondeja commented 2 months ago

git has a standard convention - for preserving an empty directory. Insert a zero sized file named EMPTY.

I had never heard of that convention. The practice that I have encountered the most is to create a file named .gitkeep or simply .keep.

martinfrances107 commented 2 months ago

.gitkeep is very explict -- I will alter the PR and follow that convention... one sec

gbj commented 2 months ago

Thanks!