web / lib/jobs/handlers/cleanup-stuck-scheduled-ingests-job
lib/jobs/handlers/cleanup-stuck-scheduled-ingests-job
Job handler for cleaning up stuck scheduled ingests.
Identifies and resets scheduled ingests that have been stuck in “running”
status for too long (default 4 hours). The threshold is intentionally generous
because lastRun records the trigger/queue time, not when processing actually
started — there can be significant delay due to queue backlog or worker restarts.
Before resetting, also checks whether a Payload job is still actively processing the ingest to avoid killing in-progress work.
Interfaces
CleanupStuckScheduledIngestsJobInput
Properties
stuckThresholdHours?
optionalstuckThresholdHours?:number
Hours after which a running import is considered stuck (default: 4).
Uses 4h because lastRun is the trigger time, not when processing started.
dryRun?
optionaldryRun?:boolean
Whether to run in dry-run mode (default: false)
Variables
cleanupStuckScheduledIngestsJob
constcleanupStuckScheduledIngestsJob:object
Type Declaration
slug
slug:
string="cleanup-stuck-scheduled-ingests"
schedule
schedule:
object[]
concurrency
concurrency: () =>
string
Returns
string
handler
handler: (
context) =>Promise<{ output: \{ success: boolean; totalRunning: number; stuckCount: number; resetCount: number; dryRun: boolean; errors: object[] \| undefined; }; }>
Parameters
context
Returns
Promise<{ output: \{ success: boolean; totalRunning: number; stuckCount: number; resetCount: number; dryRun: boolean; errors: object[] \| undefined; }; }>