mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-19 11:28:38 +00:00
fix(cron): preserve manual timeoutSeconds on add
This commit is contained in:
@@ -1,5 +1,29 @@
|
|||||||
|
import { normalizeLegacyDeliveryInput } from "../legacy-delivery.js";
|
||||||
import type { CronDelivery, CronJobCreate } from "../types.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 {
|
export function resolveInitialCronDelivery(input: CronJobCreate): CronDelivery | undefined {
|
||||||
if (input.delivery) {
|
if (input.delivery) {
|
||||||
return input.delivery;
|
return input.delivery;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { normalizeCronJobCreate } from "../normalize.js";
|
|
||||||
import type { CronJob, CronJobCreate, CronJobPatch } from "../types.js";
|
import type { CronJob, CronJobCreate, CronJobPatch } from "../types.js";
|
||||||
|
import { normalizeCronCreateDeliveryInput } from "./initial-delivery.js";
|
||||||
import {
|
import {
|
||||||
applyJobPatch,
|
applyJobPatch,
|
||||||
computeJobNextRunAtMs,
|
computeJobNextRunAtMs,
|
||||||
@@ -235,10 +235,7 @@ export async function add(state: CronServiceState, input: CronJobCreate) {
|
|||||||
return await locked(state, async () => {
|
return await locked(state, async () => {
|
||||||
warnIfDisabled(state, "add");
|
warnIfDisabled(state, "add");
|
||||||
await ensureLoaded(state);
|
await ensureLoaded(state);
|
||||||
const normalizedInput = normalizeCronJobCreate(input);
|
const normalizedInput = normalizeCronCreateDeliveryInput(input);
|
||||||
if (!normalizedInput) {
|
|
||||||
throw new Error("invalid cron job input");
|
|
||||||
}
|
|
||||||
const job = createJob(state, normalizedInput);
|
const job = createJob(state, normalizedInput);
|
||||||
state.store?.jobs.push(job);
|
state.store?.jobs.push(job);
|
||||||
|
|
||||||
|
|||||||
@@ -47,10 +47,12 @@ const registryCache = new Map<string, PluginRegistry>();
|
|||||||
|
|
||||||
const defaultLogger = () => createSubsystemLogger("plugins");
|
const defaultLogger = () => createSubsystemLogger("plugins");
|
||||||
|
|
||||||
|
type PluginSdkAliasCandidateKind = "dist" | "src";
|
||||||
|
|
||||||
function resolvePluginSdkAliasCandidateOrder(params: {
|
function resolvePluginSdkAliasCandidateOrder(params: {
|
||||||
modulePath: string;
|
modulePath: string;
|
||||||
isProduction: boolean;
|
isProduction: boolean;
|
||||||
}) {
|
}): PluginSdkAliasCandidateKind[] {
|
||||||
const normalizedModulePath = params.modulePath.replace(/\\/g, "/");
|
const normalizedModulePath = params.modulePath.replace(/\\/g, "/");
|
||||||
const isDistRuntime = normalizedModulePath.includes("/dist/");
|
const isDistRuntime = normalizedModulePath.includes("/dist/");
|
||||||
return isDistRuntime || params.isProduction ? ["dist", "src"] : ["src", "dist"];
|
return isDistRuntime || params.isProduction ? ["dist", "src"] : ["src", "dist"];
|
||||||
|
|||||||
Reference in New Issue
Block a user