Files
Eric Allam 6d0884254e feat: Add maxDuration to tasks (#1377)
* WIP

* Get max duration working on deployed runs

* Actually set the timed out runs to status = TIMED_OUT

* The client status for TIMED_OUT is now MAX_DURATION_EXCEEDED

* New TimedOutIcon

* Added new timedout icon

* Add ability to opt-out of maxDuration with timeout.None

* MAX_DURATION_EXCEEDED -> TIMED_OUT

* changeset

* Improved styling for the status tooltip content

---------

Co-authored-by: James Ritchie <james@trigger.dev>
2024-10-03 12:43:26 -07:00

23 lines
649 B
TypeScript

const MINIMUM_MAX_DURATION = 5;
const MAXIMUM_MAX_DURATION = 2_147_483_647; // largest 32-bit signed integer
export function clampMaxDuration(maxDuration: number): number {
return Math.min(Math.max(maxDuration, MINIMUM_MAX_DURATION), MAXIMUM_MAX_DURATION);
}
export function getMaxDuration(
maxDuration?: number | null,
defaultMaxDuration?: number | null
): number | undefined {
if (!maxDuration) {
return defaultMaxDuration ?? undefined;
}
// Setting the maxDuration to MAXIMUM_MAX_DURATION means we don't want to use the default maxDuration
if (maxDuration === MAXIMUM_MAX_DURATION) {
return;
}
return maxDuration;
}