maxDuration
to prevent a task from running too long. You can set the maxDuration
for a run in the following ways:
- Across all your tasks in the config
- On a specific task
- On a specific run when you trigger a task
How it works
ThemaxDuration
is set in seconds, and is compared to the CPU time elapsed since the start of a single execution (which we call attempts) of the task. The CPU time is the time that the task has been actively running on the CPU, and does not include time spent waiting during the following:
wait.for
callstriggerAndWait
callsbatchTriggerAndWait
calls
usage
utility:
/trigger/max-duration.ts
maxDuration
you set. If the task exceeds the maxDuration
, it will be stopped with the following error:

The minimum maxDuration is 5 seconds. The maximum is ~68 years.
Configuring a default max duration
You can set a defaultmaxDuration
for all tasks in your config file. This will apply to all tasks unless you override it on a specific task or run.
/config/default-max-duration.ts
Configuring for a task
You can set amaxDuration
on a specific task:
/trigger/max-duration-task.ts
maxDuration
set in the config file. If you have a config file with a default maxDuration
of 60 seconds, and you set a maxDuration
of 300 seconds on a task, the task will run for 300 seconds.
You can “turn off” the Max duration set in your config file for a specific task like so:
/trigger/max-duration-task.ts
Configuring for a run
You can set amaxDuration
on a specific run when you trigger a task:
/trigger/max-duration.ts
maxDuration
to timeout.None
to turn off the max duration for a specific run:
/trigger/max-duration.ts
maxDuration in run context
You can access themaxDuration
set for a run in the run context:
/trigger/max-duration-task.ts
maxDuration and lifecycle functions
When a task run exceeds themaxDuration
, the lifecycle functions cleanup
, onSuccess
, and onFailure
will not be called.