fix(cron): preserve manual timeoutSeconds on add

This commit is contained in:
Peter Steinberger 2026-03-08 00:45:38 +00:00
parent e66c418c45
commit 149ae45bad
3 changed files with 29 additions and 6 deletions

View File

@ -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<string, unknown>)
: null;
const deliveryRecord =
input.delivery && typeof input.delivery === "object"
? ({ ...input.delivery } as Record<string, unknown>)
: 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;

View File

@ -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);

View File

@ -47,10 +47,12 @@ const registryCache = new Map<string, PluginRegistry>();
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"];