mirror of
https://github.com/hansjone/dsh-ops-cron.git
synced 2026-10-09 04:40:48 +08:00
Fix cron cwd for super_admin and harden IM channel job isolation.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
b35bfde557
commit
b1bb0067a0
16 changed files with 714 additions and 49 deletions
14
lib/store.js
14
lib/store.js
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue