@@ -31,6 +31,7 @@ import {
3131 TaskRunExecutionResult ,
3232 TaskRunPromise ,
3333} from "@trigger.dev/core/v3" ;
34+ import { resolveMaxComputeSeconds } from "./maxComputeSeconds.js" ;
3435import { tracer } from "./tracer.js" ;
3536
3637import type {
@@ -235,7 +236,7 @@ export function createTask<
235236 queue : params . queue ,
236237 retry : params . retry ? { ...defaultRetryOptions , ...params . retry } : undefined ,
237238 machine : typeof params . machine === "string" ? { preset : params . machine } : params . machine ,
238- maxDuration : params . maxDuration ,
239+ maxDuration : resolveMaxComputeSeconds ( params ) ,
239240 ttl : params . ttl ,
240241 payloadSchema : params . jsonSchema ,
241242 fns : {
@@ -367,7 +368,7 @@ export function createSchemaTask<
367368 queue : params . queue ,
368369 retry : params . retry ? { ...defaultRetryOptions , ...params . retry } : undefined ,
369370 machine : typeof params . machine === "string" ? { preset : params . machine } : params . machine ,
370- maxDuration : params . maxDuration ,
371+ maxDuration : resolveMaxComputeSeconds ( params ) ,
371372 ttl : params . ttl ,
372373 fns : {
373374 run : params . run ,
@@ -643,7 +644,7 @@ export async function batchTriggerById<TTask extends AnyTask>(
643644 tags : item . options ?. tags ,
644645 maxAttempts : item . options ?. maxAttempts ,
645646 metadata : item . options ?. metadata ,
646- maxDuration : item . options ?. maxDuration ,
647+ maxDuration : item . options ? resolveMaxComputeSeconds ( item . options ) : undefined ,
647648 idempotencyKey :
648649 ( await makeIdempotencyKey ( item . options ?. idempotencyKey ) ) ?? batchItemIdempotencyKey ,
649650 idempotencyKeyTTL : item . options ?. idempotencyKeyTTL ?? options ?. idempotencyKeyTTL ,
@@ -900,7 +901,7 @@ export async function batchTriggerByIdAndWait<TTask extends AnyTask>(
900901 tags : item . options ?. tags ,
901902 maxAttempts : item . options ?. maxAttempts ,
902903 metadata : item . options ?. metadata ,
903- maxDuration : item . options ?. maxDuration ,
904+ maxDuration : item . options ? resolveMaxComputeSeconds ( item . options ) : undefined ,
904905 idempotencyKey :
905906 ( await makeIdempotencyKey ( item . options ?. idempotencyKey ) ) ?? batchItemIdempotencyKey ,
906907 idempotencyKeyTTL : item . options ?. idempotencyKeyTTL ?? options ?. idempotencyKeyTTL ,
@@ -1159,7 +1160,7 @@ export async function batchTriggerTasks<TTasks extends readonly AnyTask[]>(
11591160 tags : item . options ?. tags ,
11601161 maxAttempts : item . options ?. maxAttempts ,
11611162 metadata : item . options ?. metadata ,
1162- maxDuration : item . options ?. maxDuration ,
1163+ maxDuration : item . options ? resolveMaxComputeSeconds ( item . options ) : undefined ,
11631164 idempotencyKey :
11641165 ( await makeIdempotencyKey ( item . options ?. idempotencyKey ) ) ?? batchItemIdempotencyKey ,
11651166 idempotencyKeyTTL : item . options ?. idempotencyKeyTTL ?? options ?. idempotencyKeyTTL ,
@@ -1421,7 +1422,7 @@ export async function batchTriggerAndWaitTasks<TTasks extends readonly AnyTask[]
14211422 tags : item . options ?. tags ,
14221423 maxAttempts : item . options ?. maxAttempts ,
14231424 metadata : item . options ?. metadata ,
1424- maxDuration : item . options ?. maxDuration ,
1425+ maxDuration : item . options ? resolveMaxComputeSeconds ( item . options ) : undefined ,
14251426 idempotencyKey :
14261427 ( await makeIdempotencyKey ( item . options ?. idempotencyKey ) ) ?? batchItemIdempotencyKey ,
14271428 idempotencyKeyTTL : item . options ?. idempotencyKeyTTL ?? options ?. idempotencyKeyTTL ,
@@ -1823,7 +1824,7 @@ async function* transformBatchItemsStream<TTask extends AnyTask>(
18231824 tags : item . options ?. tags ,
18241825 maxAttempts : item . options ?. maxAttempts ,
18251826 metadata : item . options ?. metadata ,
1826- maxDuration : item . options ?. maxDuration ,
1827+ maxDuration : item . options ? resolveMaxComputeSeconds ( item . options ) : undefined ,
18271828 idempotencyKey :
18281829 ( await makeIdempotencyKey ( item . options ?. idempotencyKey ) ) ?? batchItemIdempotencyKey ,
18291830 idempotencyKeyTTL : item . options ?. idempotencyKeyTTL ?? options ?. idempotencyKeyTTL ,
@@ -1876,7 +1877,7 @@ async function* transformBatchItemsStreamForWait<TTask extends AnyTask>(
18761877 tags : item . options ?. tags ,
18771878 maxAttempts : item . options ?. maxAttempts ,
18781879 metadata : item . options ?. metadata ,
1879- maxDuration : item . options ?. maxDuration ,
1880+ maxDuration : item . options ? resolveMaxComputeSeconds ( item . options ) : undefined ,
18801881 idempotencyKey :
18811882 ( await makeIdempotencyKey ( item . options ?. idempotencyKey ) ) ?? batchItemIdempotencyKey ,
18821883 idempotencyKeyTTL : item . options ?. idempotencyKeyTTL ?? options ?. idempotencyKeyTTL ,
@@ -1926,7 +1927,7 @@ async function* transformBatchByTaskItemsStream<TTasks extends readonly AnyTask[
19261927 tags : item . options ?. tags ,
19271928 maxAttempts : item . options ?. maxAttempts ,
19281929 metadata : item . options ?. metadata ,
1929- maxDuration : item . options ?. maxDuration ,
1930+ maxDuration : item . options ? resolveMaxComputeSeconds ( item . options ) : undefined ,
19301931 idempotencyKey :
19311932 ( await makeIdempotencyKey ( item . options ?. idempotencyKey ) ) ?? batchItemIdempotencyKey ,
19321933 idempotencyKeyTTL : item . options ?. idempotencyKeyTTL ?? options ?. idempotencyKeyTTL ,
@@ -1978,7 +1979,7 @@ async function* transformBatchByTaskItemsStreamForWait<TTasks extends readonly A
19781979 tags : item . options ?. tags ,
19791980 maxAttempts : item . options ?. maxAttempts ,
19801981 metadata : item . options ?. metadata ,
1981- maxDuration : item . options ?. maxDuration ,
1982+ maxDuration : item . options ? resolveMaxComputeSeconds ( item . options ) : undefined ,
19821983 idempotencyKey :
19831984 ( await makeIdempotencyKey ( item . options ?. idempotencyKey ) ) ?? batchItemIdempotencyKey ,
19841985 idempotencyKeyTTL : item . options ?. idempotencyKeyTTL ?? options ?. idempotencyKeyTTL ,
@@ -2030,7 +2031,7 @@ async function* transformSingleTaskBatchItemsStream<TPayload>(
20302031 tags : item . options ?. tags ,
20312032 maxAttempts : item . options ?. maxAttempts ,
20322033 metadata : item . options ?. metadata ,
2033- maxDuration : item . options ?. maxDuration ,
2034+ maxDuration : item . options ? resolveMaxComputeSeconds ( item . options ) : undefined ,
20342035 idempotencyKey :
20352036 ( await makeIdempotencyKey ( item . options ?. idempotencyKey ) ) ?? batchItemIdempotencyKey ,
20362037 idempotencyKeyTTL : item . options ?. idempotencyKeyTTL ?? options ?. idempotencyKeyTTL ,
@@ -2091,7 +2092,7 @@ async function* transformSingleTaskBatchItemsStreamForWait<TPayload>(
20912092 tags : item . options ?. tags ,
20922093 maxAttempts : item . options ?. maxAttempts ,
20932094 metadata : item . options ?. metadata ,
2094- maxDuration : item . options ?. maxDuration ,
2095+ maxDuration : item . options ? resolveMaxComputeSeconds ( item . options ) : undefined ,
20952096 idempotencyKey : finalIdempotencyKey ?. toString ( ) ,
20962097 idempotencyKeyTTL : item . options ?. idempotencyKeyTTL ?? options ?. idempotencyKeyTTL ,
20972098 idempotencyKeyOptions,
@@ -2141,7 +2142,7 @@ async function trigger_internal<TRunTypes extends AnyRunTypes>(
21412142 tags : options ?. tags ,
21422143 maxAttempts : options ?. maxAttempts ,
21432144 metadata : options ?. metadata ,
2144- maxDuration : options ?. maxDuration ,
2145+ maxDuration : options ? resolveMaxComputeSeconds ( options ) : undefined ,
21452146 parentRunId : taskContext . ctx ?. run . id ,
21462147 machine : options ?. machine ,
21472148 priority : options ?. priority ,
@@ -2225,7 +2226,7 @@ async function batchTrigger_internal<TRunTypes extends AnyRunTypes>(
22252226 tags : item . options ?. tags ,
22262227 maxAttempts : item . options ?. maxAttempts ,
22272228 metadata : item . options ?. metadata ,
2228- maxDuration : item . options ?. maxDuration ,
2229+ maxDuration : item . options ? resolveMaxComputeSeconds ( item . options ) : undefined ,
22292230 idempotencyKey : finalIdempotencyKey ?. toString ( ) ,
22302231 idempotencyKeyTTL : item . options ?. idempotencyKeyTTL ?? options ?. idempotencyKeyTTL ,
22312232 idempotencyKeyOptions,
@@ -2398,7 +2399,7 @@ async function triggerAndWait_internal<TIdentifier extends string, TPayload, TOu
23982399 tags : options ?. tags ,
23992400 maxAttempts : options ?. maxAttempts ,
24002401 metadata : options ?. metadata ,
2401- maxDuration : options ?. maxDuration ,
2402+ maxDuration : options ? resolveMaxComputeSeconds ( options ) : undefined ,
24022403 resumeParentOnCompletion : true ,
24032404 parentRunId : ctx . run . id ,
24042405 idempotencyKey : processedIdempotencyKey ?. toString ( ) ,
@@ -2500,7 +2501,7 @@ async function batchTriggerAndWait_internal<TIdentifier extends string, TPayload
25002501 tags : item . options ?. tags ,
25012502 maxAttempts : item . options ?. maxAttempts ,
25022503 metadata : item . options ?. metadata ,
2503- maxDuration : item . options ?. maxDuration ,
2504+ maxDuration : item . options ? resolveMaxComputeSeconds ( item . options ) : undefined ,
25042505 idempotencyKey : finalIdempotencyKey ?. toString ( ) ,
25052506 idempotencyKeyTTL : item . options ?. idempotencyKeyTTL ?? options ?. idempotencyKeyTTL ,
25062507 idempotencyKeyOptions,
0 commit comments