You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/runs/max-duration.mdx
+19-18Lines changed: 19 additions & 18 deletions
Original file line number
Diff line number
Diff line change
@@ -4,15 +4,32 @@ sidebarTitle: "Max duration"
4
4
description: "Set a maximum duration for a task to run."
5
5
---
6
6
7
-
By default tasks can execute indefinitely, which can be great! But you also might want to set a `maxDuration` to prevent a task from running too long. You can set the `maxDuration` for a run in the following ways:
7
+
The `maxDuration` parameter sets a maximum compute time limit for tasks. When a task exceeds this duration, it will be automatically stopped. This helps prevent runaway tasks and manage compute resources effectively.
8
+
9
+
You must set a default maxDuration in your `trigger.config.ts` file, which will apply to all tasks unless overridden:
The minimum maxDuration is 5 seconds. If you want to avoid timeouts, set this value to a very large number of seconds.
22
+
</Note>
23
+
24
+
You can set the `maxDuration` for a run in the following ways:
8
25
9
26
- Across all your tasks in the [config](/config/config-file#max-duration)
10
27
- On a specific task
11
28
- On a specific run when you [trigger a task](/triggering#maxduration)
12
29
13
30
## How it works
14
31
15
-
The `maxDuration` 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:
32
+
The `maxDuration` is set in seconds, and is compared to the CPU time elapsed since the start of a single execution (which we call [attempts](/runs#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:
16
33
17
34
-`wait.for` calls
18
35
-`triggerAndWait` calls
@@ -38,22 +55,6 @@ The above value will be compared to the `maxDuration` you set. If the task excee
<Note>The minimum maxDuration is 5 seconds. The maximum is ~68 years.</Note>
42
-
43
-
## Configuring a default max duration
44
-
45
-
You can set a default `maxDuration` for all tasks in your [config file](/config/config-file#default-machine). This will apply to all tasks unless you override it on a specific task or run.
0 commit comments