fix: add watcher debounce for rapid successive file changes

When Micropub creates a post, the markdown file is written twice in quick
succession — first the initial content, then ~2s later a syndication update
adds syndication URLs. Without debouncing, the watcher rebuilds from the
first write and misses the second, causing "Also on" links to not appear.

- awaitWriteFinish (2s stability threshold): delays watcher events until
  the file hasn't been written to for 2 seconds
- setWatchThrottleWaitTime (3s): groups all file changes within 3 seconds
  into a single build

Confab-Link: http://localhost:8080/sessions/956f4251-b4a9-4bc9-b214-53402ad1fe63
This commit is contained in:
Ricardo
2026-03-01 21:27:54 +01:00
parent 00b436f76f
commit c3d64afa23
+14
View File
@@ -53,6 +53,20 @@ export default function (eleventyConfig) {
eleventyConfig.watchIgnores.add(".cache/unfurl");
eleventyConfig.watchIgnores.add(".cache/unfurl/**");
// Watcher tuning: handle rapid successive file changes
// When a post is created via Micropub, the file is written twice in quick
// succession: first the initial content, then ~2s later a Micropub update
// adds syndication URLs. awaitWriteFinish delays the watcher event until
// the file is stable (no writes for 2s), so both changes are captured in
// one build. The throttle adds a 3s build-level debounce on top.
eleventyConfig.setChokidarConfig({
awaitWriteFinish: {
stabilityThreshold: 2000,
pollInterval: 100,
},
});
eleventyConfig.setWatchThrottleWaitTime(3000);
// Configure markdown-it with linkify enabled (auto-convert URLs to links)
const md = markdownIt({
html: true,