Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

web: fix error when registering task with invalid time (fixes #4890)

Abdullah Atta6e47eae30a0c
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<TaskSchedulerType> | 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) {