Trigger.dev, the background jobs platform with no timeouts, is proud to announce the release of timeouts (but only when you want them).
You can now set a maxDuration
for a task, for when you want to prevent runaway tasks:
_10import { task } from "@trigger.dev/sdk/v3";_10_10export const maxDurationTask = task({_10 id: "max-duration-task",_10 maxDuration: 300, // 300 seconds or 5 minutes_10 run: async (payload: { foo: string }) => {_10 //..._10 },_10});
Or you can set a global maxDuration
for all tasks in your project:
_10import { defineConfig } from "@trigger.dev/sdk/v3";_10_10export default defineConfig({_10 maxDuration: 300, // 300 seconds or 5 minutes_10});
You can even set a specific maxDuration
for a run when you trigger a task:
_10import { maxDurationTask } from "./trigger/max-duration-task";_10_10// Trigger the task with a maxDuration of 300 seconds_10// This will override the default maxDuration set in the config file_10const run = await maxDurationTask.trigger(_10 { foo: "bar" },_10 {_10 maxDuration: 300, // 300 seconds or 5 minutes_10 }_10);
Read all about the maxDuration
feature in the docs.
Update
Max duration is available starting from @trigger.dev/sdk
version 3.0.10
, upgrade using npx trigger.dev@latest update
. If you are self-hosting, upgrade to version 3.0.10 or later of the server image.