From 149ae45bad4d27c2b1821c6cad5c77fdf62089dc Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sun, 8 Mar 2026 00:45:38 +0000 Subject: [PATCH] fix(cron): preserve manual timeoutSeconds on add --- src/cron/service/initial-delivery.ts | 24 ++++++++++++++++++++++++ src/cron/service/ops.ts | 7 ++----- src/plugins/loader.ts | 4 +++- 3 files changed, 29 insertions(+), 6 deletions(-) diff --git a/src/cron/service/initial-delivery.ts b/src/cron/service/initial-delivery.ts index 9dc2eb908d5..c490e3a4247 100644 --- a/src/cron/service/initial-delivery.ts +++ b/src/cron/service/initial-delivery.ts @@ -1,5 +1,29 @@ +import { normalizeLegacyDeliveryInput } from "../legacy-delivery.js"; import type { CronDelivery, CronJobCreate } from "../types.js"; +export function normalizeCronCreateDeliveryInput(input: CronJobCreate): CronJobCreate { + const payloadRecord = + input.payload && typeof input.payload === "object" + ? ({ ...input.payload } as Record) + : null; + const deliveryRecord = + input.delivery && typeof input.delivery === "object" + ? ({ ...input.delivery } as Record) + : null; + const normalizedLegacy = normalizeLegacyDeliveryInput({ + delivery: deliveryRecord, + payload: payloadRecord, + }); + if (!normalizedLegacy.mutated) { + return input; + } + return { + ...input, + payload: payloadRecord ? (payloadRecord as typeof input.payload) : input.payload, + delivery: (normalizedLegacy.delivery as CronDelivery | undefined) ?? input.delivery, + }; +} + export function resolveInitialCronDelivery(input: CronJobCreate): CronDelivery | undefined { if (input.delivery) { return input.delivery; diff --git a/src/cron/service/ops.ts b/src/cron/service/ops.ts index 2b86b7253c2..9f575134c23 100644 --- a/src/cron/service/ops.ts +++ b/src/cron/service/ops.ts @@ -1,5 +1,5 @@ -import { normalizeCronJobCreate } from "../normalize.js"; import type { CronJob, CronJobCreate, CronJobPatch } from "../types.js"; +import { normalizeCronCreateDeliveryInput } from "./initial-delivery.js"; import { applyJobPatch, computeJobNextRunAtMs, @@ -235,10 +235,7 @@ export async function add(state: CronServiceState, input: CronJobCreate) { return await locked(state, async () => { warnIfDisabled(state, "add"); await ensureLoaded(state); - const normalizedInput = normalizeCronJobCreate(input); - if (!normalizedInput) { - throw new Error("invalid cron job input"); - } + const normalizedInput = normalizeCronCreateDeliveryInput(input); const job = createJob(state, normalizedInput); state.store?.jobs.push(job); diff --git a/src/plugins/loader.ts b/src/plugins/loader.ts index 6460b45c945..073e735a707 100644 --- a/src/plugins/loader.ts +++ b/src/plugins/loader.ts @@ -47,10 +47,12 @@ const registryCache = new Map(); const defaultLogger = () => createSubsystemLogger("plugins"); +type PluginSdkAliasCandidateKind = "dist" | "src"; + function resolvePluginSdkAliasCandidateOrder(params: { modulePath: string; isProduction: boolean; -}) { +}): PluginSdkAliasCandidateKind[] { const normalizedModulePath = params.modulePath.replace(/\\/g, "/"); const isDistRuntime = normalizedModulePath.includes("/dist/"); return isDistRuntime || params.isProduction ? ["dist", "src"] : ["src", "dist"];