From c96a0074f87f084801289cc9852f27221e4720e9 Mon Sep 17 00:00:00 2001 From: Dries Augustyns Date: Wed, 25 Sep 2024 15:39:37 +0200 Subject: [PATCH] Fix: Added try/catch to CRON --- package.json | 2 +- packages/api/src/app/cron.ts | 22 ++++++++++++++++------ 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index 65c31dc..cf7f793 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "plunk", - "version": "1.0.6", + "version": "1.0.7", "private": true, "license": "agpl-3.0", "workspaces": { diff --git a/packages/api/src/app/cron.ts b/packages/api/src/app/cron.ts index 54ac4a9..8b4c9f9 100644 --- a/packages/api/src/app/cron.ts +++ b/packages/api/src/app/cron.ts @@ -4,12 +4,22 @@ import { API_URI } from "./constants"; export const task = cron.schedule("* * * * *", () => { signale.info("Running scheduled tasks"); - void fetch(`${API_URI}/tasks`, { - method: "POST", - }); + try { + void fetch(`${API_URI}/tasks`, { + method: "POST", + }); + } catch (e) { + signale.error("Failed to run scheduled tasks. Please check the error below"); + console.error(e); + } signale.info("Updating verified identities"); - void fetch(`${API_URI}/identities/update`, { - method: "POST", - }); + try { + void fetch(`${API_URI}/identities/update`, { + method: "POST", + }); + } catch (e) { + signale.error("Failed to update verified identities. Please check the error below"); + console.error(e); + } });