fix: queue on-create jobs sequentially and fix history ordering
runJobsOnCreate now awaits each job before starting the next, ensuring they don't stomp each other's DB writes in parallel. getInstanceHistory changed to ORDER BY changed_at ASC, id ASC so the creation event (lowest id) is always first regardless of same-second timestamps. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -132,7 +132,9 @@ const _intervals = new Map();
|
||||
export async function runJobsOnCreate() {
|
||||
for (const job of getJobs()) {
|
||||
const cfg = JSON.parse(job.config || '{}');
|
||||
if (cfg.run_on_create) runJob(job.id).catch(e => console.error(`runJobsOnCreate job ${job.id}:`, e));
|
||||
if (cfg.run_on_create) {
|
||||
try { await runJob(job.id); } catch (e) { console.error(`runJobsOnCreate job ${job.id}:`, e); }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user