chore(cron): simplify enabled checks for lint

This commit is contained in:
Gustavo Madeira Santana
2026-02-15 10:19:50 -05:00
parent fa4c282f9e
commit 88caa4b50c
3 changed files with 14 additions and 21 deletions

View File

@@ -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") {