Skip to content

Commit 723d9df

Browse files
committed
serve: Fix repeated error message when HTML config is invalid
This fixes an issue where `mdbook serve` would repeatedly show an error message every second if the `output.html` config had a problem. The issue is that `set_roots` was doing more work than I realized. It is not necessary to call it every time in the main polling loop, since the roots only change when the book configuration changes. The solution is to just reset the roots whenever the book config changes. Fixes #2946
1 parent f857ab2 commit 723d9df

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/cmd/watch/poller.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ pub fn rebuild_on_change(
4141

4242
loop {
4343
std::thread::sleep(Duration::new(1, 0));
44-
watcher.set_roots(&book);
4544
let start = Instant::now();
4645
let paths = watcher.scan();
4746
let elapsed = start.elapsed().as_secs_f64();
@@ -67,6 +66,7 @@ pub fn rebuild_on_change(
6766
post_build();
6867
}
6968
book = b;
69+
watcher.set_roots(&book);
7070
}
7171
Err(e) => error!("failed to load book config: {e:?}"),
7272
}

0 commit comments

Comments
 (0)