From fb59d202004184662fd26c51c484263bb6f0080d Mon Sep 17 00:00:00 2001 From: Adrian Altner Date: Wed, 22 Apr 2026 02:13:39 +0200 Subject: [PATCH] Add invocation counter and logging to track fetch calls in getMentionsFor function --- src/lib/webmentions.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lib/webmentions.ts b/src/lib/webmentions.ts index 5379b87..4f7de25 100644 --- a/src/lib/webmentions.ts +++ b/src/lib/webmentions.ts @@ -40,7 +40,7 @@ interface WMResponse { const API = 'https://webmention.io/api/mentions.jf2'; -const perTargetCache = new Map(); +let invocationCounter = 0; async function fetchForTarget(target: string): Promise { const token = import.meta.env.WEBMENTION_TOKEN; @@ -73,8 +73,8 @@ export async function getMentionsFor(target: string | URL): Promise { const withSlash = canonical.endsWith('/') ? canonical : `${canonical}/`; const withoutSlash = canonical.replace(/\/+$/, ''); - const cached = perTargetCache.get(canonical); - if (cached) return cached; + const invocation = ++invocationCounter; + console.log(`[webmentions getMentionsFor #${invocation}] target=${canonical}`); const [a, b] = await Promise.all([fetchForTarget(withSlash), fetchForTarget(withoutSlash)]); const seen = new Set(); @@ -86,7 +86,7 @@ export async function getMentionsFor(target: string | URL): Promise { merged.push(m); } - perTargetCache.set(canonical, merged); + console.log(`[webmentions getMentionsFor #${invocation}] returning ${merged.length} mentions for ${canonical}`); return merged; }