From c3d64afa234fef746a0dff786080ca8dcf45f03c Mon Sep 17 00:00:00 2001 From: Ricardo Date: Sun, 1 Mar 2026 21:27:54 +0100 Subject: [PATCH] fix: add watcher debounce for rapid successive file changes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- eleventy.config.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/eleventy.config.js b/eleventy.config.js index 2b55c2d..483d43a 100644 --- a/eleventy.config.js +++ b/eleventy.config.js @@ -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,