#How long into the future can I `delay` a run?
1 messages · Page 1 of 1 (latest)
Hi @fallen jungle. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
You can delay a run in Trigger.dev for extended periods, including 1 month or even 6 months into the future. The delay option accepts durations like "1h", "10m", or even longer periods such as "1month" or "6months", as well as absolute dates (e.g., a specific ISO date string or a JavaScript Date object). Example usage:
await myTask.trigger({ some: "data" }, { delay: "1month" });
await myTask.trigger({ some: "data" }, { delay: new Date("2024-12-01T00:00:00") });
There is no explicit maximum delay duration mentioned in the documentation, so you can schedule tasks far into the future. The system is designed to handle long delays, and delayed runs will be enqueued and executed as soon as possible after the specified time. You can also reschedule or cancel delayed runs if needed Triggering Options.
Is it recommended?
Delaying a run for months is supported and can be appropriate for certain use cases. However, if you need to run a task on a recurring schedule (e.g., every month), it's better to use a scheduled (cron) task instead of a one-off delay. For a single future execution, using delay is suitable. For recurring tasks, use the scheduled task feature Scheduled tasks (cron).
Summary:
- You can delay a run for 1 month, 6 months, or more.
- Use
delayfor one-off future executions. - Use scheduled tasks for recurring jobs.
- Both approaches are supported and recommended depending on your use case.