mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 04:17:42 +00:00
chore(cron): simplify enabled checks for lint
This commit is contained in:
@@ -90,7 +90,7 @@ function applyJobResult(
|
||||
"cron: disabling one-shot job after error",
|
||||
);
|
||||
}
|
||||
} else if (result.status === "error" && job.enabled !== false) {
|
||||
} else if (result.status === "error" && job.enabled) {
|
||||
// Apply exponential backoff for errored jobs to prevent retry storms.
|
||||
const backoff = errorBackoffMs(job.state.consecutiveErrors ?? 1);
|
||||
const normalNext = computeJobNextRunAtMs(job, result.endedAt);
|
||||
@@ -107,7 +107,7 @@ function applyJobResult(
|
||||
},
|
||||
"cron: applying error backoff",
|
||||
);
|
||||
} else if (job.enabled !== false) {
|
||||
} else if (job.enabled) {
|
||||
job.state.nextRunAtMs = computeJobNextRunAtMs(job, result.endedAt);
|
||||
} else {
|
||||
job.state.nextRunAtMs = undefined;
|
||||
@@ -129,11 +129,10 @@ export function armTimer(state: CronServiceState) {
|
||||
const nextAt = nextWakeAtMs(state);
|
||||
if (!nextAt) {
|
||||
const jobCount = state.store?.jobs.length ?? 0;
|
||||
const enabledCount = state.store?.jobs.filter((j) => j.enabled !== false).length ?? 0;
|
||||
const enabledCount = state.store?.jobs.filter((j) => j.enabled).length ?? 0;
|
||||
const withNextRun =
|
||||
state.store?.jobs.filter(
|
||||
(j) => j.enabled !== false && typeof j.state.nextRunAtMs === "number",
|
||||
).length ?? 0;
|
||||
state.store?.jobs.filter((j) => j.enabled && typeof j.state.nextRunAtMs === "number")
|
||||
.length ?? 0;
|
||||
state.deps.log.debug(
|
||||
{ jobCount, enabledCount, withNextRun },
|
||||
"cron: armTimer skipped - no jobs with nextRunAtMs",
|
||||
@@ -347,7 +346,7 @@ function findDueJobs(state: CronServiceState): CronJob[] {
|
||||
if (!j.state) {
|
||||
j.state = {};
|
||||
}
|
||||
if (j.enabled === false) {
|
||||
if (!j.enabled) {
|
||||
return false;
|
||||
}
|
||||
if (typeof j.state.runningAtMs === "number") {
|
||||
@@ -371,7 +370,7 @@ export async function runMissedJobs(
|
||||
if (!j.state) {
|
||||
j.state = {};
|
||||
}
|
||||
if (j.enabled === false) {
|
||||
if (!j.enabled) {
|
||||
return false;
|
||||
}
|
||||
if (skipJobIds?.has(j.id)) {
|
||||
@@ -410,7 +409,7 @@ export async function runDueJobs(state: CronServiceState) {
|
||||
if (!j.state) {
|
||||
j.state = {};
|
||||
}
|
||||
if (j.enabled === false) {
|
||||
if (!j.enabled) {
|
||||
return false;
|
||||
}
|
||||
if (typeof j.state.runningAtMs === "number") {
|
||||
|
||||
Reference in New Issue
Block a user