Skip to content

Open-source status page, incident response and uptime monitoring

Bug cron (#128)

Thibault Le Ouayc516b32ead39
diff --git a/apps/web/src/app/api/checker/cron/_cron.ts b/apps/web/src/app/api/checker/cron/_cron.ts
index 2b58fa520..9f97bfd67 100644
--- a/apps/web/src/app/api/checker/cron/_cron.ts
+++ b/apps/web/src/app/api/checker/cron/_cron.ts
@@ -52,8 +52,7 @@ export const cron = async ({
.where(eq(monitorsToPages.monitorId, row.id))
.all();
- const allMonitorsRegions = currentRegions.parse(row.regions);
- if (allMonitorsRegions.length === 0) {
+ if (row.regions.length === 0) {
const payload: z.infer<typeof payloadSchema> = {
workspaceId: String(row.workspaceId),
monitorId: String(row.id),
@@ -70,6 +69,7 @@ export const cron = async ({
});
allResult.push(result);
} else {
+ const allMonitorsRegions = currentRegions.parse(row.regions);
for (const region of allMonitorsRegions) {
const payload: z.infer<typeof payloadSchema> = {
workspaceId: String(row.workspaceId),
diff --git a/packages/db/src/schema/monitor.ts b/packages/db/src/schema/monitor.ts
index dfabe0a8d..ffe7cc576 100644
--- a/packages/db/src/schema/monitor.ts
+++ b/packages/db/src/schema/monitor.ts
@@ -123,7 +123,11 @@ export const selectMonitorSchema = createSelectSchema(monitor, {
jobType: z.enum(["website", "cron", "other"]).default("other"),
active: z.boolean().default(false),
regions: z
- .preprocess((val) => String(val).split(","), z.array(RegionEnum))
+ .preprocess((val) => {
+ if (String(val).length > 0) {
+ return String(val).split(",");
+ }
+ }, z.array(RegionEnum))
.default([]),
});