fix: pass timezone when removing repeatable schedule job

removeJob() for type 'schedule' computed the BullMQ repeatable key
using only the cron pattern, without the timezone. scheduleJob()
always registers the repeatable job with tz set (job.timezone || UTC),
so BullMQ's repeat key (name:jobId:endDate:tz:pattern) never matched
on removal — removeRepeatable silently no-op'd and the job kept
firing forever, surviving disable, delete, and reboots.

Forward timezone through removeJob (queue.ts), the /update-backup
lookup (index.ts), and the disable/delete call sites in the
schedule router.
This commit is contained in:
Mauricio Siu 2026-09-01 01:31:59 -06:00
parent 91bcf88df9
commit 4e38925119
3 changed files with 5 additions and 1 deletions

View File

@ -141,6 +141,7 @@ export const scheduleRouter = createTRPCRouter({
cronSchedule: updatedSchedule.cronExpression,
scheduleId: updatedSchedule.scheduleId,
type: "schedule",
timezone: updatedSchedule.timezone,
});
}
} else {
@ -185,6 +186,7 @@ export const scheduleRouter = createTRPCRouter({
cronSchedule: scheduleItem.cronExpression,
scheduleId: scheduleItem.scheduleId,
type: "schedule",
timezone: scheduleItem.timezone,
});
} else {
removeScheduleJob(scheduleItem.scheduleId);

View File

@ -60,6 +60,7 @@ app.post("/update-backup", zValidator("json", jobQueueSchema), async (c) => {
scheduleId: data.scheduleId,
type: "schedule",
cronSchedule: job.pattern || "",
timezone: job.tz || data.timezone,
});
} else if (data.type === "volume-backup") {
result = await removeJob({

View File

@ -66,9 +66,10 @@ export const removeJob = async (data: QueueJob) => {
return result;
}
if (data.type === "schedule") {
const { scheduleId, cronSchedule } = data;
const { scheduleId, cronSchedule, timezone } = data;
const result = await jobQueue.removeRepeatable(scheduleId, {
pattern: cronSchedule,
tz: timezone || "UTC",
});
return result;
}