-
Couldn't load subscription status.
- Fork 1.8k
Description
Problem
Editing non-.md files in the book's source folder triggers multiple rebuilds when using mdbook serve. The amount of rebuilds is not constant, I've seen it vary from 2 to over 20 times. Editing markdown files triggers a single rebuild.
Steps
cd $(mktemp -d)mdbook init </dev/nullecho "export let lorem = 'ipsum';" > src/test.tsecho -e '```\n{{#include test.ts}}\n```' >> src/chapter_1.mdmdbook serve- in a second terminal:
touch src/test.ts
Possible Solution(s)
Switching notify from macos_fsevent to macos_kqueue seems to fix the issue, triggering only a single rebuild whenever the src/test.ts file changes.
Notes
This happens on an APFS drive on macOS. It doesn't happen on ext4 in a linux VM.
I'm not sure why this happens. A simple test using the following code doesn't trigger the multitude of events, leading me to think the cause lies within mdbook and not in notify.
use std::{path::Path, thread::sleep, time::Duration};
use notify::RecursiveMode;
fn main() {
let mut debouncer =
notify_debouncer_mini::new_debouncer(Duration::from_secs(1), None, |event| {
println!("event {:#?}", event);
})
.unwrap();
let watcher = debouncer.watcher();
watcher
.watch(Path::new("."), RecursiveMode::Recursive)
.unwrap();
loop {
sleep(Duration::from_millis(500));
}
}Version
mdbook v0.4.32 (also happens on v0.4.31, earlier versions not tested)