-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Labels
C-bugCategory: A bug, incorrect or unintended behaviorCategory: A bug, incorrect or unintended behaviorCommand-watchCommand: watchCommand: watchE-Help-wantedExperience: Help NeededExperience: Help Needed
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/null
echo "export let lorem = 'ipsum';" > src/test.ts
echo -e '```\n{{#include test.ts}}\n```' >> src/chapter_1.md
mdbook 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)
Metadata
Metadata
Assignees
Labels
C-bugCategory: A bug, incorrect or unintended behaviorCategory: A bug, incorrect or unintended behaviorCommand-watchCommand: watchCommand: watchE-Help-wantedExperience: Help NeededExperience: Help Needed