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:
import { task } from "@trigger.dev/sdk/v3";export const maxDurationTask = task({ id: "max-duration-task", maxDuration: 300, // 300 seconds or 5 minutes run: async (payload: { foo: string }) => { //... },});
Or you can set a global maxDuration
for all tasks in your project:
import { defineConfig } from "@trigger.dev/sdk/v3";export default defineConfig({ maxDuration: 300, // 300 seconds or 5 minutes});
You can even set a specific maxDuration
for a run when you trigger a task:
import { maxDurationTask } from "./trigger/max-duration-task";// Trigger the task with a maxDuration of 300 seconds// This will override the default maxDuration set in the config fileconst run = await maxDurationTask.trigger( { foo: "bar" }, { maxDuration: 300, // 300 seconds or 5 minutes });
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.