{"record":{"id":"cdc2e619c820c4fc","repo":"paperclipai/paperclip","slug":"job-job-jobkey-is-already-running-cannot-tr","errorCode":null,"errorMessage":"Job \"${job.jobKey}\" is already running — cannot trigger while in progress","messagePattern":"Job \"(.+?)\" is already running — cannot trigger while in progress","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/src/services/plugin-job-scheduler.ts","lineNumber":456,"sourceCode":"\n  async function triggerJob(\n    jobId: string,\n    trigger: \"manual\" | \"retry\" = \"manual\",\n  ): Promise<TriggerJobResult> {\n    const job = await jobStore.getJobById(jobId);\n    if (!job) {\n      throw new Error(`Job not found: ${jobId}`);\n    }\n\n    if (job.status !== \"active\") {\n      throw new Error(\n        `Job \"${job.jobKey}\" is not active (status: ${job.status})`,\n      );\n    }\n\n    // Overlap prevention\n    if (activeJobs.has(jobId)) {\n      throw new Error(\n        `Job \"${job.jobKey}\" is already running — cannot trigger while in progress`,\n      );\n    }\n\n    // Also check DB for running runs (defensive — covers multi-instance)\n    const existingRuns = await db\n      .select()\n      .from(pluginJobRuns)\n      .where(\n        and(\n          eq(pluginJobRuns.jobId, jobId),\n          eq(pluginJobRuns.status, \"running\"),\n        ),\n      );\n\n    if (existingRuns.length > 0) {\n      throw new Error(\n        `Job \"${job.jobKey}\" already has a running execution — cannot trigger while in progress`,","sourceCodeStart":438,"sourceCodeEnd":474,"githubUrl":"https://github.com/paperclipai/paperclip/blob/120ae5428fa29bee300bcf806491cd4d965fbb7c/server/src/services/plugin-job-scheduler.ts#L438-L474","documentation":"Overlap guard (in-memory) in triggerJob: activeJobs already contains this jobId, meaning this instance is currently executing the job. Prevents concurrent duplicate runs; the in-flight execution is at fault.","triggerScenarios":"Thrown at server/src/services/plugin-job-scheduler.ts:456 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Wait for the current execution to finish before triggering again; poll the job's running state or add idempotency on the caller side."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"120ae5428fa29bee300bcf806491cd4d965fbb7c","analyzedAt":"2026-08-18T22:49:45.177Z","contentChangedAt":"2026-08-18T22:49:45.177Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}