From c9dec3d321fe302adb10458fb6f2394f3ed2a0d8 Mon Sep 17 00:00:00 2001 From: Michael Bishop Date: Wed, 7 Jan 2026 19:52:43 -0500 Subject: [PATCH 1/2] Improve error handling to prevent build failures Changes error handling from rejecting promises to logging warnings, allowing the build to complete even when webmention discovery encounters timeouts or other transient errors. Previously, any error in webmention discovery would fail the entire Netlify build via utils.build.failPlugin(). This change catches errors, logs them as warnings, and tracks the error count while still completing the build successfully. Also updates @remy/webmention dependency from ^1.4.5 to ^1.5.0. --- index.js | 57 ++++++++++++++++++++++++++++------------------------ package.json | 2 +- 2 files changed, 32 insertions(+), 27 deletions(-) diff --git a/index.js b/index.js index 2eb5bc5..188b680 100644 --- a/index.js +++ b/index.js @@ -21,37 +21,42 @@ module.exports = { return; } - try { - await new Promise((resolve, reject) => { - console.log( - `Discovering Webmentions in ${feedUrl} with a limit of ${limit} ${ - limit === 1 ? "entry" : "entries" - }` - ); - console.log(""); + let errorCount = 0; - const wm = new Webmention({ limit, send: true }); + await new Promise((resolve) => { + console.log( + `Discovering Webmentions in ${feedUrl} with a limit of ${limit} ${ + limit === 1 ? "entry" : "entries" + }` + ); + console.log(""); - wm.on("error", (e) => reject(e)); + const wm = new Webmention({ limit, send: true }); - wm.on("sent", (res) => { - console.log( - `Sent ${res.source} to ${res.endpoint.url} (${res.endpoint.type})` - ); - if (res.error) { - console.log(`Error sending to ${res.endpoint.url}: ${res.error}`); - } - console.log(""); - }); + wm.on("error", (e) => { + // Log errors but continue - timeouts shouldn't fail the build + console.log(`Warning: ${e.message || e}`); + errorCount++; + }); - wm.on("end", () => { - resolve(); - }); + wm.on("sent", (res) => { + console.log( + `Sent ${res.source} to ${res.endpoint.url} (${res.endpoint.type})` + ); + if (res.error) { + console.log(`Error sending to ${res.endpoint.url}: ${res.error}`); + } + console.log(""); + }); - wm.fetch(feedUrl); + wm.on("end", () => { + if (errorCount > 0) { + console.log(`Completed with ${errorCount} warning(s)`); + } + resolve(); }); - } catch (e) { - utils.build.failPlugin(e); - } + + wm.fetch(feedUrl); + }); }, }; diff --git a/package.json b/package.json index 2260784..05d469e 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ }, "homepage": "https://github.com/CodeFoodPixels/netlify-plugin-webmentions#readme", "dependencies": { - "@remy/webmention": "^1.4.5" + "@remy/webmention": "^1.5.0" }, "devDependencies": { "prettier": "^2.2.1" From 5e54a081cd91ed3172bbc67a9f627a907e5332a3 Mon Sep 17 00:00:00 2001 From: Michael Bishop Date: Wed, 7 Jan 2026 20:42:23 -0500 Subject: [PATCH 2/2] add temp note on how to use fork to override plugins --- README.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/README.md b/README.md index bee513c..0b059c3 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,17 @@ # Netlify Build Plugin: Automatically discover any webmentions and send them after every production build +> **Note:** This is a fork of [CodeFoodPixels/netlify-plugin-webmentions](https://github.com/CodeFoodPixels/netlify-plugin-webmentions) with improved error handling that logs warnings instead of failing the build on timeouts/errors. +> +> To use this fork instead of the npm package (which also overrides the Netlify app plugin): +> ```bash +> npm install -D github:miklb/netlify-plugin-webmentions +> ``` +> Then add to `netlify.toml`: +> ```toml +> [[plugins]] +> package = "netlify-plugin-webmentions" +> ``` + Automatically discover any webmentions and send them after every production build. This plugin will send webmentions to any mentioned websites that have a webmention endpoint after every production build. The plugin can be used without any configuration if using the defaults.