From 6e47eae30a0cc93345b8a2397f915b369285f81e Mon Sep 17 00:00:00 2001 From: Abdullah Atta Date: Tue, 10 Sep 2024 09:41:16 +0500 Subject: [PATCH] web: fix error when registering task with invalid time (fixes #4890) --- apps/web/src/utils/task-scheduler.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/apps/web/src/utils/task-scheduler.ts b/apps/web/src/utils/task-scheduler.ts index 14cf37cc2..922e34f52 100644 --- a/apps/web/src/utils/task-scheduler.ts +++ b/apps/web/src/utils/task-scheduler.ts @@ -24,12 +24,19 @@ import type { } from "./task-scheduler.worker"; import { wrap, Remote } from "comlink"; import { showToast } from "./toast"; +import dayjs from "dayjs"; +import { logger } from "./logger"; let worker: globalThis.Worker | undefined; let scheduler: Remote | undefined; export class TaskScheduler { static async register(id: string, time: string, action: () => void) { + if (!dayjs(time).isValid()) { + logger.error(`Invalid cron expression: ${time}`); + return; + } + init(); worker?.addEventListener("message", function handler(ev) {