Panic when watching auto-rebulding blog
This is _probably_ a bug in `notify`, and it really warrants more investigation on my side, but I don't have time for this right now, so I'll log the issue as I've got it.
Feel free to ignore this! While I am sure it is actionable (there's an honest-to-god panic), I bet this'll be fiddly to debug.
When running `deno task watch & live-server --port 8080` in https://github.com/matklad/matklad.github.io, I got the following panic:
```
src/main.ts watch
[2024-03-22T10:28:45Z INFO live_server::server] Listening on http://172.20.10.6:8080/
[2024-03-22T10:28:45Z INFO live_server::watcher] Listening on /home/matklad/p/matklad.github.io
thread 'tokio-runtime-worker' panicked at /home/matklad/.cargo/registry/src/index.crates.io-6f17d22bba15001f/live-server-0.7.0/src/watcher.rs:74:10:
called `Result::unwrap()` on an `Err` value: Error { kind: Io(Os { code: 2, kind: NotFound, message: "No such file or directory" }), paths: ["/home/matklad/p/matklad.github.io/out/res/2021/11/07"] }
stack backtrace:
Watcher Process started.
0: rust_begin_unwind
at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panicking.rs:645:5
1: core::panicking::panic_fmt
at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/panicking.rs:72:14
2: core::result::unwrap_failed
at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/result.rs:1649:5
3: live_server::watcher::watch::{{closure}}
4: std::panicking::try
5: tokio::runtime::task::harness::Harness<T,S>::poll
6: tokio::runtime::scheduler::multi_thread::worker::Context::run_task
7: tokio::runtime::scheduler::multi_thread::worker::Context::run
8: tokio::runtime::context::scoped::Scoped<T>::set
9: tokio::runtime::context::runtime::enter_runtime
10: tokio::runtime::scheduler::multi_thread::worker::run
11: <tokio::runtime::blocking::task::BlockingTask<T> as core::future::future::Future>::poll
12: tokio::runtime::task::core::Core<T,S>::poll
13: tokio::runtime::task::harness::Harness<T,S>::poll
14: tokio::runtime::blocking::pool::Inner::run
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
thread 'main' panicked at /home/matklad/.cargo/registry/src/index.crates.io-6f17d22bba15001f/live-server-0.7.0/src/main.rs:43:28:
called `Result::unwrap()` on an `Err` value: JoinError::Panic(Id(22), ...)
stack backtrace:
0: rust_begin_unwind
at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panicking.rs:645:5
1: core::panicking::panic_fmt
at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/panicking.rs:72:14
2: core::result::unwrap_failed
at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/result.rs:1649:5
3: tokio::runtime::park::CachedParkThread::block_on::{{closure}}
4: tokio::runtime::context::blocking::BlockingRegionGuard::block_on
5: tokio::runtime::context::runtime::enter_runtime
6: tokio::runtime::runtime::Runtime::block_on
7: live_server::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
```
Notably, the "root" path there should be `/home/matklad/p/matklad.github.io/`! The `out` directory is the one that's deleted and re-created by `deno task watch` part.
So, it looks like what's happening here is that you ask notify to watch `./`, it interanlly races to read `./out/res/2021/11/07`, and that fails. This is _normal_: we are watching fs for changes, of course we are expected files to go out of existence from under our nose! What is strage is that notify propagates this error all the way up to watcher creation, and fails the entire operation.
Thanks for live-server by the way, its best in class from what I can tell, no nonsense, does exactly what I need it to!
关闭于 2024-03-22 1 条评论