Handle errors while revalidating
This commit is contained in:
parent
39a0382318
commit
7feccde653
|
@ -7,12 +7,18 @@ import type { EndpointChange } from "src/shared/payload/webhooks";
|
||||||
export const webhookHandler = async (changes: EndpointChange[]) => {
|
export const webhookHandler = async (changes: EndpointChange[]) => {
|
||||||
const index = meili.index(MeiliIndexes.DOCUMENT);
|
const index = meili.index(MeiliIndexes.DOCUMENT);
|
||||||
|
|
||||||
|
console.log("[Webhook] Received the following message", changes);
|
||||||
|
|
||||||
const documents: MeiliDocument[] = [];
|
const documents: MeiliDocument[] = [];
|
||||||
for (const change of changes) {
|
for (const change of changes) {
|
||||||
await index.deleteDocuments({
|
await index.deleteDocuments({
|
||||||
filter: `endpointCalled = "${change.url}"`,
|
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");
|
console.log("[Webhook] Adding", documents.length, "documents to Meilisearch");
|
||||||
|
|
Loading…
Reference in New Issue