Fix cron cwd for super_admin and harden IM channel job isolation.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
oliver 2026-09-10 10:00:59 +08:00
parent b35bfde557
commit b1bb0067a0
16 changed files with 714 additions and 49 deletions

View file

@ -133,10 +133,16 @@ export function createJobRecord(input, state, now) {
lastStatus: null,
nextRunAt: nextFire(schedule, now, schedule.timezone),
}
if (schedule.kind === 'at' && (job.nextRunAt == null || job.nextRunAt < now - 60_000)) {
const error = new Error(`that one-shot time is already in the past (now is ${new Date(now).toISOString()})`)
error.code = 'INVALID_AT'
throw error
if (schedule.kind === 'at') {
const atMs = Date.parse(job.schedule.at)
// Slightly past (within 60s): fire on next tick instead of rejecting or freezing.
if (Number.isFinite(atMs) && atMs <= now && atMs >= now - 60_000) {
job.nextRunAt = now
} else if (job.nextRunAt == null || job.nextRunAt < now - 60_000) {
const error = new Error(`that one-shot time is already in the past (now is ${new Date(now).toISOString()})`)
error.code = 'INVALID_AT'
throw error
}
}
return job
}