Skip to content

Commit 6a24aeb

Browse files
committed
maxComputeSeconds
Deprecate maxDuration in favour of maxComputeSeconds but keep backwards compatibility
1 parent 8003923 commit 6a24aeb

File tree

12 files changed

+66
-33
lines changed

12 files changed

+66
-33
lines changed

.claude/skills/trigger-dev-tasks/advanced-tasks.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ In trailing mode, these options update with each trigger:
166166
- `metadata` — run metadata
167167
- `tags` — run tags (replaces existing)
168168
- `maxAttempts` — retry attempts
169-
- `maxDuration` — maximum compute time
169+
- `maxComputeSeconds` — maximum compute time in seconds
170170
- `machine` — machine preset
171171

172172
### Important Notes
@@ -274,7 +274,7 @@ export const resilientTask = task({
274274
export const heavyTask = task({
275275
id: "heavy-computation",
276276
machine: { preset: "large-2x" }, // 8 vCPU, 16 GB RAM
277-
maxDuration: 1800, // 30 minutes timeout
277+
maxComputeSeconds: 1800, // 30 minutes timeout
278278
run: async (payload, { ctx }) => {
279279
// Resource-intensive computation
280280
if (ctx.machine.preset === "large-2x") {

.claude/skills/trigger-dev-tasks/config.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ export default defineConfig({
295295
export default defineConfig({
296296
// ... other config
297297
defaultMachine: "large-1x", // Default machine for all tasks
298-
maxDuration: 300, // Default max duration (seconds)
298+
maxComputeSeconds: 300, // Default max compute time (seconds)
299299
enableConsoleLogging: true, // Console logging in development
300300
});
301301
```

apps/webapp/app/components/runs/v3/ReplayRunDialog.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ function ReplayForm({
479479
<FormError id={maxAttempts.errorId}>{maxAttempts.error}</FormError>
480480
</InputGroup>
481481
<InputGroup>
482-
<Label variant="small">Max duration</Label>
482+
<Label variant="small">Max compute time</Label>
483483
<DurationPicker
484484
name={maxDurationSeconds.name}
485485
id={maxDurationSeconds.id}

apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.test.tasks.$taskParam/route.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -742,7 +742,7 @@ function StandardTaskForm({
742742
<FormError id={maxAttempts.errorId}>{maxAttempts.error}</FormError>
743743
</InputGroup>
744744
<InputGroup>
745-
<Label variant="small">Max duration</Label>
745+
<Label variant="small">Max compute time</Label>
746746
<DurationPicker
747747
name={maxDurationSeconds.name}
748748
id={maxDurationSeconds.id}
@@ -1318,7 +1318,7 @@ function ScheduledTaskForm({
13181318
</InputGroup>
13191319
<InputGroup>
13201320
<Label htmlFor={maxDurationSeconds.id} variant="small">
1321-
Max duration
1321+
Max compute time
13221322
</Label>
13231323
<DurationPicker
13241324
name={maxDurationSeconds.name}

apps/webapp/app/routes/resources.orgs.$organizationSlug.projects.$projectParam.env.$envParam.runs.$runParam.spans.$spanParam/route.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -869,7 +869,7 @@ function RunBody({
869869
</Property.Value>
870870
</Property.Item>
871871
<Property.Item>
872-
<Property.Label>Max duration</Property.Label>
872+
<Property.Label>Max compute time</Property.Label>
873873
<Property.Value>
874874
{run.maxDurationInSeconds
875875
? `${run.maxDurationInSeconds}s (${formatDurationMilliseconds(

packages/cli-v3/src/entryPoints/dev-index-worker.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,13 +117,14 @@ if (config.retries?.default) {
117117
});
118118
}
119119

120-
// If the config has a maxDuration, we need to apply it to all tasks that don't have a maxDuration
121-
if (typeof config.maxDuration === "number") {
120+
// If the config has a maxComputeSeconds or maxDuration, we need to apply it to all tasks that don't have a maxDuration
121+
const configMaxDuration = config.maxComputeSeconds ?? config.maxDuration;
122+
if (typeof configMaxDuration === "number") {
122123
tasks = tasks.map((task) => {
123124
if (typeof task.maxDuration !== "number") {
124125
return {
125126
...task,
126-
maxDuration: config.maxDuration,
127+
maxDuration: configMaxDuration,
127128
} satisfies TaskManifest;
128129
}
129130

packages/cli-v3/src/entryPoints/managed-index-worker.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,13 +117,14 @@ if (config.retries?.default) {
117117
});
118118
}
119119

120-
// If the config has a maxDuration, we need to apply it to all tasks that don't have a maxDuration
121-
if (typeof config.maxDuration === "number") {
120+
// If the config has a maxComputeSeconds or maxDuration, we need to apply it to all tasks that don't have a maxDuration
121+
const configMaxDuration = config.maxComputeSeconds ?? config.maxDuration;
122+
if (typeof configMaxDuration === "number") {
122123
tasks = tasks.map((task) => {
123124
if (typeof task.maxDuration !== "number") {
124125
return {
125126
...task,
126-
maxDuration: config.maxDuration,
127+
maxDuration: configMaxDuration,
127128
} satisfies TaskManifest;
128129
}
129130

packages/core/src/v3/config.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,11 +170,22 @@ export type TriggerConfig = {
170170
*
171171
* Minimum value is 5 seconds
172172
*
173-
* Setting this value will effect all tasks in the project.
173+
* Setting this value will affect all tasks in the project.
174174
*
175-
* @see https://trigger.dev/docs/tasks/overview#maxduration-option
175+
* @see https://trigger.dev/docs/tasks/overview#maxcomputeseconds-option
176176
*/
177-
maxDuration: number;
177+
maxComputeSeconds?: number;
178+
179+
/**
180+
* @deprecated Use `maxComputeSeconds` instead. This property will be removed in a future version.
181+
*
182+
* The maximum duration in compute-time seconds that a task run is allowed to run. If the task run exceeds this duration, it will be stopped.
183+
*
184+
* Minimum value is 5 seconds
185+
*
186+
* Setting this value will affect all tasks in the project.
187+
*/
188+
maxDuration?: number;
178189

179190
/**
180191
* Enable console logging while running the dev CLI. This will print out logs from console.log, console.warn, and console.error. By default all logs are sent to the trigger.dev backend, and not logged to the console.

packages/core/src/v3/types/tasks.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,15 @@ type CommonTaskOptions<
275275
*
276276
* Minimum value is 5 seconds
277277
*/
278+
maxComputeSeconds?: number;
279+
280+
/**
281+
* @deprecated Use `maxComputeSeconds` instead. This property will be removed in a future version.
282+
*
283+
* The maximum duration in compute-time seconds that a task run is allowed to run. If the task run exceeds this duration, it will be stopped.
284+
*
285+
* Minimum value is 5 seconds
286+
*/
278287
maxDuration?: number;
279288

280289
/** This gets called when a task is triggered. It's where you put the code you want to execute.
@@ -853,6 +862,17 @@ export type TriggerOptions = {
853862
metadata?: Record<string, SerializableJson>;
854863

855864
/**
865+
* The maximum duration in compute-time seconds that a task run is allowed to run. If the task run exceeds this duration, it will be stopped.
866+
*
867+
* This will override the task's maxComputeSeconds.
868+
*
869+
* Minimum value is 5 seconds
870+
*/
871+
maxComputeSeconds?: number;
872+
873+
/**
874+
* @deprecated Use `maxComputeSeconds` instead. This property will be removed in a future version.
875+
*
856876
* The maximum duration in compute-time seconds that a task run is allowed to run. If the task run exceeds this duration, it will be stopped.
857877
*
858878
* This will override the task's maxDuration.

packages/trigger-sdk/src/v3/shared.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ export function createTask<
235235
queue: params.queue,
236236
retry: params.retry ? { ...defaultRetryOptions, ...params.retry } : undefined,
237237
machine: typeof params.machine === "string" ? { preset: params.machine } : params.machine,
238-
maxDuration: params.maxDuration,
238+
maxDuration: params.maxComputeSeconds ?? params.maxDuration,
239239
payloadSchema: params.jsonSchema,
240240
fns: {
241241
run: params.run,
@@ -641,7 +641,7 @@ export async function batchTriggerById<TTask extends AnyTask>(
641641
tags: item.options?.tags,
642642
maxAttempts: item.options?.maxAttempts,
643643
metadata: item.options?.metadata,
644-
maxDuration: item.options?.maxDuration,
644+
maxDuration: item.options?.maxComputeSeconds ?? item.options?.maxDuration,
645645
idempotencyKey:
646646
(await makeIdempotencyKey(item.options?.idempotencyKey)) ?? batchItemIdempotencyKey,
647647
idempotencyKeyTTL: item.options?.idempotencyKeyTTL ?? options?.idempotencyKeyTTL,
@@ -898,7 +898,7 @@ export async function batchTriggerByIdAndWait<TTask extends AnyTask>(
898898
tags: item.options?.tags,
899899
maxAttempts: item.options?.maxAttempts,
900900
metadata: item.options?.metadata,
901-
maxDuration: item.options?.maxDuration,
901+
maxDuration: item.options?.maxComputeSeconds ?? item.options?.maxDuration,
902902
idempotencyKey:
903903
(await makeIdempotencyKey(item.options?.idempotencyKey)) ?? batchItemIdempotencyKey,
904904
idempotencyKeyTTL: item.options?.idempotencyKeyTTL ?? options?.idempotencyKeyTTL,
@@ -1157,7 +1157,7 @@ export async function batchTriggerTasks<TTasks extends readonly AnyTask[]>(
11571157
tags: item.options?.tags,
11581158
maxAttempts: item.options?.maxAttempts,
11591159
metadata: item.options?.metadata,
1160-
maxDuration: item.options?.maxDuration,
1160+
maxDuration: item.options?.maxComputeSeconds ?? item.options?.maxDuration,
11611161
idempotencyKey:
11621162
(await makeIdempotencyKey(item.options?.idempotencyKey)) ?? batchItemIdempotencyKey,
11631163
idempotencyKeyTTL: item.options?.idempotencyKeyTTL ?? options?.idempotencyKeyTTL,
@@ -1419,7 +1419,7 @@ export async function batchTriggerAndWaitTasks<TTasks extends readonly AnyTask[]
14191419
tags: item.options?.tags,
14201420
maxAttempts: item.options?.maxAttempts,
14211421
metadata: item.options?.metadata,
1422-
maxDuration: item.options?.maxDuration,
1422+
maxDuration: item.options?.maxComputeSeconds ?? item.options?.maxDuration,
14231423
idempotencyKey:
14241424
(await makeIdempotencyKey(item.options?.idempotencyKey)) ?? batchItemIdempotencyKey,
14251425
idempotencyKeyTTL: item.options?.idempotencyKeyTTL ?? options?.idempotencyKeyTTL,
@@ -1821,7 +1821,7 @@ async function* transformBatchItemsStream<TTask extends AnyTask>(
18211821
tags: item.options?.tags,
18221822
maxAttempts: item.options?.maxAttempts,
18231823
metadata: item.options?.metadata,
1824-
maxDuration: item.options?.maxDuration,
1824+
maxDuration: item.options?.maxComputeSeconds ?? item.options?.maxDuration,
18251825
idempotencyKey:
18261826
(await makeIdempotencyKey(item.options?.idempotencyKey)) ?? batchItemIdempotencyKey,
18271827
idempotencyKeyTTL: item.options?.idempotencyKeyTTL ?? options?.idempotencyKeyTTL,
@@ -1874,7 +1874,7 @@ async function* transformBatchItemsStreamForWait<TTask extends AnyTask>(
18741874
tags: item.options?.tags,
18751875
maxAttempts: item.options?.maxAttempts,
18761876
metadata: item.options?.metadata,
1877-
maxDuration: item.options?.maxDuration,
1877+
maxDuration: item.options?.maxComputeSeconds ?? item.options?.maxDuration,
18781878
idempotencyKey:
18791879
(await makeIdempotencyKey(item.options?.idempotencyKey)) ?? batchItemIdempotencyKey,
18801880
idempotencyKeyTTL: item.options?.idempotencyKeyTTL ?? options?.idempotencyKeyTTL,
@@ -1924,7 +1924,7 @@ async function* transformBatchByTaskItemsStream<TTasks extends readonly AnyTask[
19241924
tags: item.options?.tags,
19251925
maxAttempts: item.options?.maxAttempts,
19261926
metadata: item.options?.metadata,
1927-
maxDuration: item.options?.maxDuration,
1927+
maxDuration: item.options?.maxComputeSeconds ?? item.options?.maxDuration,
19281928
idempotencyKey:
19291929
(await makeIdempotencyKey(item.options?.idempotencyKey)) ?? batchItemIdempotencyKey,
19301930
idempotencyKeyTTL: item.options?.idempotencyKeyTTL ?? options?.idempotencyKeyTTL,
@@ -1976,7 +1976,7 @@ async function* transformBatchByTaskItemsStreamForWait<TTasks extends readonly A
19761976
tags: item.options?.tags,
19771977
maxAttempts: item.options?.maxAttempts,
19781978
metadata: item.options?.metadata,
1979-
maxDuration: item.options?.maxDuration,
1979+
maxDuration: item.options?.maxComputeSeconds ?? item.options?.maxDuration,
19801980
idempotencyKey:
19811981
(await makeIdempotencyKey(item.options?.idempotencyKey)) ?? batchItemIdempotencyKey,
19821982
idempotencyKeyTTL: item.options?.idempotencyKeyTTL ?? options?.idempotencyKeyTTL,
@@ -2028,7 +2028,7 @@ async function* transformSingleTaskBatchItemsStream<TPayload>(
20282028
tags: item.options?.tags,
20292029
maxAttempts: item.options?.maxAttempts,
20302030
metadata: item.options?.metadata,
2031-
maxDuration: item.options?.maxDuration,
2031+
maxDuration: item.options?.maxComputeSeconds ?? item.options?.maxDuration,
20322032
idempotencyKey:
20332033
(await makeIdempotencyKey(item.options?.idempotencyKey)) ?? batchItemIdempotencyKey,
20342034
idempotencyKeyTTL: item.options?.idempotencyKeyTTL ?? options?.idempotencyKeyTTL,
@@ -2089,7 +2089,7 @@ async function* transformSingleTaskBatchItemsStreamForWait<TPayload>(
20892089
tags: item.options?.tags,
20902090
maxAttempts: item.options?.maxAttempts,
20912091
metadata: item.options?.metadata,
2092-
maxDuration: item.options?.maxDuration,
2092+
maxDuration: item.options?.maxComputeSeconds ?? item.options?.maxDuration,
20932093
idempotencyKey: finalIdempotencyKey?.toString(),
20942094
idempotencyKeyTTL: item.options?.idempotencyKeyTTL ?? options?.idempotencyKeyTTL,
20952095
idempotencyKeyOptions,
@@ -2139,7 +2139,7 @@ async function trigger_internal<TRunTypes extends AnyRunTypes>(
21392139
tags: options?.tags,
21402140
maxAttempts: options?.maxAttempts,
21412141
metadata: options?.metadata,
2142-
maxDuration: options?.maxDuration,
2142+
maxDuration: options?.maxComputeSeconds ?? options?.maxDuration,
21432143
parentRunId: taskContext.ctx?.run.id,
21442144
machine: options?.machine,
21452145
priority: options?.priority,
@@ -2223,7 +2223,7 @@ async function batchTrigger_internal<TRunTypes extends AnyRunTypes>(
22232223
tags: item.options?.tags,
22242224
maxAttempts: item.options?.maxAttempts,
22252225
metadata: item.options?.metadata,
2226-
maxDuration: item.options?.maxDuration,
2226+
maxDuration: item.options?.maxComputeSeconds ?? item.options?.maxDuration,
22272227
idempotencyKey: finalIdempotencyKey?.toString(),
22282228
idempotencyKeyTTL: item.options?.idempotencyKeyTTL ?? options?.idempotencyKeyTTL,
22292229
idempotencyKeyOptions,
@@ -2498,7 +2498,7 @@ async function batchTriggerAndWait_internal<TIdentifier extends string, TPayload
24982498
tags: item.options?.tags,
24992499
maxAttempts: item.options?.maxAttempts,
25002500
metadata: item.options?.metadata,
2501-
maxDuration: item.options?.maxDuration,
2501+
maxDuration: item.options?.maxComputeSeconds ?? item.options?.maxDuration,
25022502
idempotencyKey: finalIdempotencyKey?.toString(),
25032503
idempotencyKeyTTL: item.options?.idempotencyKeyTTL ?? options?.idempotencyKeyTTL,
25042504
idempotencyKeyOptions,

0 commit comments

Comments
 (0)