Human readable error on badly configured cron

This commit is contained in:
Adria Navarro 2025-05-09 10:47:33 +02:00
parent 4a7ad25830
commit 20d16d01a7
2 changed files with 12 additions and 4 deletions

View File

@ -16,6 +16,7 @@ import {
UserCtx,
DeploymentStatus,
DeploymentProgressResponse,
Automation,
} from "@budibase/types"
import sdk from "../../../sdk"
import { builderSocket } from "../../../websockets"
@ -76,17 +77,24 @@ async function initDeployedApp(prodAppId: any) {
const db = context.getProdAppDB()
console.log("Reading automation docs")
const automations = (
await db.allDocs(
await db.allDocs<Automation>(
getAutomationParams(null, {
include_docs: true,
})
)
).rows.map((row: any) => row.doc)
).rows.map(row => row.doc!)
await clearMetadata()
const { count } = await disableAllCrons(prodAppId)
const promises = []
for (let automation of automations) {
promises.push(enableCronTrigger(prodAppId, automation))
promises.push(
enableCronTrigger(prodAppId, automation).catch(err => {
throw new Error(
`Failed to enable CRON trigger for automation "${automation.name}": ${err.message}`,
{ cause: err }
)
})
)
}
const results = await Promise.all(promises)
const enabledCount = results

View File

@ -182,7 +182,7 @@ export async function enableCronTrigger(appId: any, automation: Automation) {
!automation.disabled
) {
const inputs = trigger.inputs as CronTriggerInputs
const cronExp = inputs.cron
const cronExp = inputs.cron || ""
const validation = helpers.cron.validate(cronExp)
if (!validation.valid) {
throw new Error(