Skip to content

Commit 583553e

Browse files
committed
Docs
1 parent f4c62c3 commit 583553e

File tree

4 files changed

+52
-48
lines changed

4 files changed

+52
-48
lines changed

docs/config/config-file.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -334,21 +334,21 @@ export default defineConfig({
334334
});
335335
```
336336

337-
## Max duration
337+
## Max compute time
338338

339-
You can set the default `maxDuration` for all tasks in your project:
339+
You can set the default `maxComputeSeconds` for all tasks in your project:
340340

341341
```ts trigger.config.ts
342342
import { defineConfig } from "@trigger.dev/sdk";
343343

344344
export default defineConfig({
345345
project: "<project ref>",
346346
// Your other config settings...
347-
maxDuration: 60, // 60 seconds
347+
maxComputeSeconds: 60, // 60 seconds
348348
});
349349
```
350350

351-
See our [maxDuration guide](/runs/max-duration) for more information.
351+
See our [maxComputeSeconds guide](/runs/max-duration) for more information.
352352

353353
## Process keep alive
354354

docs/runs/max-duration.mdx

Lines changed: 41 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,39 @@
11
---
2-
title: "Max duration"
3-
sidebarTitle: "Max duration"
4-
description: "Set a maximum duration for a task to run."
2+
title: "Max compute time"
3+
sidebarTitle: "Max compute time"
4+
description: "Set a maximum compute time limit for a task to run."
55
---
66

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.
7+
The `maxComputeSeconds` 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.
88

9-
You must set a default maxDuration in your `trigger.config.ts` file, which will apply to all tasks unless overridden:
9+
<Note>
10+
`maxComputeSeconds` replaces the deprecated `maxComputeSeconds` parameter. Both work the same way, but we recommend using `maxComputeSeconds` for clarity.
11+
</Note>
12+
13+
You must set a default maxComputeSeconds in your `trigger.config.ts` file, which will apply to all tasks unless overridden:
1014

1115
```ts /config/trigger.config.ts
1216
import { defineConfig } from "@trigger.dev/sdk";
1317

1418
export default defineConfig({
1519
project: "proj_gtcwttqhhtlasxgfuhxs",
16-
maxDuration: 60, // 60 seconds or 1 minute
20+
maxComputeSeconds: 60, // 60 seconds or 1 minute
1721
});
1822
```
1923

2024
<Note>
21-
The minimum maxDuration is 5 seconds. If you want to avoid timeouts, set this value to a very large number of seconds.
25+
The minimum maxComputeSeconds is 5 seconds. If you want to avoid timeouts, set this value to a very large number of seconds.
2226
</Note>
2327

24-
You can set the `maxDuration` for a run in the following ways:
28+
You can set the `maxComputeSeconds` for a run in the following ways:
2529

26-
- Across all your tasks in the [config](/config/config-file#max-duration)
30+
- Across all your tasks in the [config](/config/config-file#max-compute-time)
2731
- On a specific task
28-
- On a specific run when you [trigger a task](/triggering#maxduration)
32+
- On a specific run when you [trigger a task](/triggering#maxcomputeseconds)
2933

3034
## How it works
3135

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:
36+
The `maxComputeSeconds` 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:
3337

3438
- `wait.for` calls
3539
- `triggerAndWait` calls
@@ -40,9 +44,9 @@ You can inspect the CPU time of a task inside the run function with our `usage`
4044
```ts /trigger/max-duration.ts
4145
import { task, usage } from "@trigger.dev/sdk";
4246

43-
export const maxDurationTask = task({
47+
export const maxComputeSecondsTask = task({
4448
id: "max-duration-task",
45-
maxDuration: 300, // 300 seconds or 5 minutes
49+
maxComputeSeconds: 300, // 300 seconds or 5 minutes
4650
run: async (payload: any, { ctx }) => {
4751
let currentUsage = usage.getCurrent();
4852

@@ -51,36 +55,36 @@ export const maxDurationTask = task({
5155
});
5256
```
5357

54-
The above value will be compared to the `maxDuration` you set. If the task exceeds the `maxDuration`, it will be stopped with the following error:
58+
The above value will be compared to the `maxComputeSeconds` you set. If the task exceeds the `maxComputeSeconds`, it will be stopped with the following error:
5559

5660
![Max duration error](/runs/max-duration-error.png)
5761

5862
## Configuring for a task
5963

60-
You can set a `maxDuration` on a specific task:
64+
You can set a `maxComputeSeconds` on a specific task:
6165

6266
```ts /trigger/max-duration-task.ts
6367
import { task } from "@trigger.dev/sdk";
6468

65-
export const maxDurationTask = task({
69+
export const maxComputeSecondsTask = task({
6670
id: "max-duration-task",
67-
maxDuration: 300, // 300 seconds or 5 minutes
71+
maxComputeSeconds: 300, // 300 seconds or 5 minutes
6872
run: async (payload: any, { ctx }) => {
6973
//...
7074
},
7175
});
7276
```
7377

74-
This will override the default `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.
78+
This will override the default `maxComputeSeconds` set in the config file. If you have a config file with a default `maxComputeSeconds` of 60 seconds, and you set a `maxComputeSeconds` of 300 seconds on a task, the task will run for 300 seconds.
7579

7680
You can "turn off" the Max duration set in your config file for a specific task like so:
7781

7882
```ts /trigger/max-duration-task.ts
7983
import { task, timeout } from "@trigger.dev/sdk";
8084

81-
export const maxDurationTask = task({
85+
export const maxComputeSecondsTask = task({
8286
id: "max-duration-task",
83-
maxDuration: timeout.None, // No max duration
87+
maxComputeSeconds: timeout.None, // No max duration
8488
run: async (payload: any, { ctx }) => {
8589
//...
8690
},
@@ -89,51 +93,51 @@ export const maxDurationTask = task({
8993

9094
## Configuring for a run
9195

92-
You can set a `maxDuration` on a specific run when you trigger a task:
96+
You can set a `maxComputeSeconds` on a specific run when you trigger a task:
9397

9498
```ts /trigger/max-duration.ts
95-
import { maxDurationTask } from "./trigger/max-duration-task";
99+
import { maxComputeSecondsTask } from "./trigger/max-duration-task";
96100

97-
// Trigger the task with a maxDuration of 300 seconds
98-
const run = await maxDurationTask.trigger(
101+
// Trigger the task with a maxComputeSeconds of 300 seconds
102+
const run = await maxComputeSecondsTask.trigger(
99103
{ foo: "bar" },
100104
{
101-
maxDuration: 300, // 300 seconds or 5 minutes
105+
maxComputeSeconds: 300, // 300 seconds or 5 minutes
102106
}
103107
);
104108
```
105109

106-
You can also set the `maxDuration` to `timeout.None` to turn off the max duration for a specific run:
110+
You can also set the `maxComputeSeconds` to `timeout.None` to turn off the max duration for a specific run:
107111

108112
```ts /trigger/max-duration.ts
109-
import { maxDurationTask } from "./trigger/max-duration-task";
113+
import { maxComputeSecondsTask } from "./trigger/max-duration-task";
110114
import { timeout } from "@trigger.dev/sdk";
111115

112-
// Trigger the task with no maxDuration
113-
const run = await maxDurationTask.trigger(
116+
// Trigger the task with no maxComputeSeconds
117+
const run = await maxComputeSecondsTask.trigger(
114118
{ foo: "bar" },
115119
{
116-
maxDuration: timeout.None, // No max duration
120+
maxComputeSeconds: timeout.None, // No max duration
117121
}
118122
);
119123
```
120124

121-
## maxDuration in run context
125+
## maxComputeSeconds in run context
122126

123-
You can access the `maxDuration` set for a run in the run context:
127+
You can access the `maxComputeSeconds` set for a run in the run context:
124128

125129
```ts /trigger/max-duration-task.ts
126130
import { task } from "@trigger.dev/sdk";
127131

128-
export const maxDurationTask = task({
132+
export const maxComputeSecondsTask = task({
129133
id: "max-duration-task",
130-
maxDuration: 300, // 300 seconds or 5 minutes
134+
maxComputeSeconds: 300, // 300 seconds or 5 minutes
131135
run: async (payload: any, { ctx }) => {
132-
console.log(ctx.run.maxDuration); // 300
136+
console.log(ctx.run.maxComputeSeconds); // 300
133137
},
134138
});
135139
```
136140

137-
## maxDuration and lifecycle functions
141+
## maxComputeSeconds and lifecycle functions
138142

139-
When a task run exceeds the `maxDuration`, the lifecycle functions `cleanup`, `onSuccess`, and `onFailure` will not be called.
143+
When a task run exceeds the `maxComputeSeconds`, the lifecycle functions `cleanup`, `onSuccess`, and `onFailure` will not be called.

docs/tasks/overview.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,21 +120,21 @@ export const heavyTask = task({
120120
});
121121
```
122122

123-
### `maxDuration` option
123+
### `maxComputeSeconds` option
124124

125-
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` on a task, and all runs of that task will be stopped if they exceed the duration.
125+
By default tasks can execute indefinitely, which can be great! But you also might want to set a `maxComputeSeconds` to prevent a task from running too long. You can set the `maxComputeSeconds` on a task, and all runs of that task will be stopped if they exceed the duration.
126126

127127
```ts /trigger/long-task.ts
128128
export const longTask = task({
129129
id: "long-task",
130-
maxDuration: 300, // 300 seconds or 5 minutes
130+
maxComputeSeconds: 300, // 300 seconds or 5 minutes
131131
run: async (payload: any, { ctx }) => {
132132
//...
133133
},
134134
});
135135
```
136136

137-
See our [maxDuration guide](/runs/max-duration) for more information.
137+
See our [maxComputeSeconds guide](/runs/max-duration) for more information.
138138

139139
## Global lifecycle hooks
140140

docs/triggering.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -932,7 +932,7 @@ Without `maxDelay`, continuous triggers would prevent the run from ever executin
932932

933933
By default, debounce uses **leading mode** - the run executes with data from the **first** trigger.
934934

935-
With **trailing mode**, each subsequent trigger updates the run's data (payload, metadata, tags, maxAttempts, maxDuration, and machine), so the run executes with data from the **last** trigger:
935+
With **trailing mode**, each subsequent trigger updates the run's data (payload, metadata, tags, maxAttempts, maxComputeSeconds, and machine), so the run executes with data from the **last** trigger:
936936

937937
```ts
938938
// Leading mode (default): runs with first payload
@@ -1090,9 +1090,9 @@ View our [tags doc](/tags) for more information.
10901090

10911091
View our [metadata doc](/runs/metadata) for more information.
10921092

1093-
### `maxDuration`
1093+
### `maxComputeSeconds`
10941094

1095-
View our [maxDuration doc](/runs/max-duration) for more information.
1095+
View our [maxComputeSeconds doc](/runs/max-duration) for more information.
10961096

10971097
### `priority`
10981098

0 commit comments

Comments
 (0)