Skip to content

Commit 4e7c559

Browse files
committed
Docs maxDuration page now states it’s a required param
1 parent 3eede3c commit 4e7c559

File tree

1 file changed

+19
-18
lines changed

1 file changed

+19
-18
lines changed

docs/runs/max-duration.mdx

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,32 @@ sidebarTitle: "Max duration"
44
description: "Set a maximum duration for a task to run."
55
---
66

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:
10+
11+
```ts /config/trigger.config.ts
12+
import { defineConfig } from "@trigger.dev/sdk/v3";
13+
14+
export default defineConfig({
15+
project: "proj_gtcwttqhhtlasxgfuhxs",
16+
maxDuration: 60, // 60 seconds or 1 minute
17+
});
18+
```
19+
20+
<Note>
21+
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:
825

926
- Across all your tasks in the [config](/config/config-file#max-duration)
1027
- On a specific task
1128
- On a specific run when you [trigger a task](/triggering#maxduration)
1229

1330
## How it works
1431

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:
1633

1734
- `wait.for` calls
1835
- `triggerAndWait` calls
@@ -38,22 +55,6 @@ The above value will be compared to the `maxDuration` you set. If the task excee
3855

3956
![Max duration error](/runs/max-duration-error.png)
4057

41-
<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.
46-
47-
```ts /config/default-max-duration.ts
48-
import { defineConfig } from "@trigger.dev/sdk/v3";
49-
50-
export default defineConfig({
51-
//Your project ref (you can see it on the Project settings page in the dashboard)
52-
project: "proj_gtcwttqhhtlasxgfuhxs",
53-
maxDuration: 60, // 60 seconds or 1 minute
54-
});
55-
```
56-
5758
## Configuring for a task
5859

5960
You can set a `maxDuration` on a specific task:

0 commit comments

Comments
 (0)