From 723d9df6c71dc781a79d2d33bd772a3b7785c01f Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Thu, 11 Dec 2025 11:21:38 -0800 Subject: [PATCH] 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 https://github.com/rust-lang/mdBook/issues/2946 --- src/cmd/watch/poller.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cmd/watch/poller.rs b/src/cmd/watch/poller.rs index 666a6c77ca..b834b67928 100644 --- a/src/cmd/watch/poller.rs +++ b/src/cmd/watch/poller.rs @@ -41,7 +41,6 @@ pub fn rebuild_on_change( loop { std::thread::sleep(Duration::new(1, 0)); - watcher.set_roots(&book); let start = Instant::now(); let paths = watcher.scan(); let elapsed = start.elapsed().as_secs_f64(); @@ -67,6 +66,7 @@ pub fn rebuild_on_change( post_build(); } book = b; + watcher.set_roots(&book); } Err(e) => error!("failed to load book config: {e:?}"), }