From 7feccde65311b613878695f71d8fb24476b45703 Mon Sep 17 00:00:00 2001 From: DrMint <29893320+DrMint@users.noreply.github.com> Date: Sun, 28 Jul 2024 22:32:58 +0200 Subject: [PATCH] Handle errors while revalidating --- src/webhook.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/webhook.ts b/src/webhook.ts index 07bc3d3..66e06d9 100644 --- a/src/webhook.ts +++ b/src/webhook.ts @@ -7,12 +7,18 @@ import type { EndpointChange } from "src/shared/payload/webhooks"; export const webhookHandler = async (changes: EndpointChange[]) => { const index = meili.index(MeiliIndexes.DOCUMENT); + console.log("[Webhook] Received the following message", changes); + const documents: MeiliDocument[] = []; for (const change of changes) { await index.deleteDocuments({ filter: `endpointCalled = "${change.url}"`, }); - documents.push(...(await convertEndpointChangeToMeiliDocuments(change))); + try { + documents.push(...(await convertEndpointChangeToMeiliDocuments(change))); + } catch (e) { + console.log("[Webhook] Failure to revalidate", change.url); + } } console.log("[Webhook] Adding", documents.length, "documents to Meilisearch");