From 4fc5701290a1202edcb4a0a244ea489845b0e872 Mon Sep 17 00:00:00 2001 From: Ricardo Date: Sun, 22 Feb 2026 01:07:52 +0100 Subject: [PATCH] fix: use one-shot flag for pagefind instead of incremental guard MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The --incremental CLI flag sets incremental=true in eleventy.after even for the watcher's first full build, so pagefind was never running when the initial build was OOM-killed. Replace the incremental guard with a pagefindDone boolean that runs pagefind exactly once per process lifetime — whichever build completes first (initial or watcher) gets indexed. --- eleventy.config.js | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/eleventy.config.js b/eleventy.config.js index bd55565..0a65c27 100644 --- a/eleventy.config.js +++ b/eleventy.config.js @@ -663,24 +663,30 @@ export default function (eleventyConfig) { }); // Post-build hook: pagefind indexing + WebSub notification - // Runs after every full build (initial + watcher's first build), skips incremental rebuilds + // Pagefind runs once on the first build (initial or watcher's first full build), then never again. + // WebSub runs on every non-incremental build. + // Note: --incremental CLI flag sets incremental=true even for the watcher's first full build, + // so we cannot use the incremental flag to guard pagefind. Use a one-shot flag instead. + let pagefindDone = false; eleventyConfig.on("eleventy.after", async ({ dir, directories, runMode, incremental }) => { - if (incremental) return; - - // Pagefind indexing — use directories.output (reflects --output CLI flag) - const outputDir = directories?.output || dir.output; - try { - console.log(`[pagefind] Indexing ${outputDir} (${runMode})...`); - execFileSync("npx", ["pagefind", "--site", outputDir, "--output-subdir", "pagefind", "--glob", "**/*.html"], { - stdio: "inherit", - timeout: 120000, - }); - console.log("[pagefind] Indexing complete"); - } catch (err) { - console.error("[pagefind] Indexing failed:", err.message); + // Pagefind indexing — run exactly once per process lifetime + if (!pagefindDone) { + pagefindDone = true; + const outputDir = directories?.output || dir.output; + try { + console.log(`[pagefind] Indexing ${outputDir} (${runMode})...`); + execFileSync("npx", ["pagefind", "--site", outputDir, "--output-subdir", "pagefind", "--glob", "**/*.html"], { + stdio: "inherit", + timeout: 120000, + }); + console.log("[pagefind] Indexing complete"); + } catch (err) { + console.error("[pagefind] Indexing failed:", err.message); + } } - // WebSub hub notification — notify subscribers of feed updates + // WebSub hub notification — skip on incremental rebuilds + if (incremental) return; const hubUrl = "https://websubhub.com/hub"; const feedUrls = [ `${siteUrl}/`,