#my triggers are now failing (time out) , but they worked before
1 messages · Page 1 of 1 (latest)
I can help troubleshoot your timeout issues with Trigger.dev. Based on the information you've provided, your triggers are failing with timeouts in production but working locally, which is a common issue.
There are a few potential causes for this:
Max Duration Limits
Your tasks might be exceeding the maximum duration limit. Trigger.dev has a maxDuration parameter that sets a compute time limit for tasks. When a task exceeds this duration, it's automatically stopped.
You need to set a default maxDuration in your trigger.config.ts file:
import { defineConfig } from "@trigger.dev/sdk/v3";
export default defineConfig({
project: "your-project-ref",
maxDuration: 60, // 60 seconds or 1 minute
});
You can also set a longer duration for specific tasks that need more time:
import { task } from "@trigger.dev/sdk/v3";
export const longRunningTask = task({
id: "long-running-task",
maxDuration: 300, // 300 seconds or 5 minutes
run: async (payload: any, { ctx }) => {
//...
},
});
Environment Variables
Since your code is deployed separately from the rest of your app, make sure that any environment variables used in your tasks are set in the Trigger.dev dashboard.
Deploy environment variables guide
Parallel Waits
The current version doesn't support performing more than one "wait" in parallel. If you're using Promise.all with wait functions, this could cause issues in production.
// This will cause problems
await Promise.all([
wait.for(...),
wait.for(...)
]);
Instead, use Trigger.dev's built-in functions for triggering tasks in parallel.
Next Steps
- Check your task's CPU time using the
usageutility to see if you're hitting duration limits - Review your code for parallel waits
- Verify all environment variables are properly set in production
- Consider using the
--dry-runflag with the deploy command to inspect your build without deploying:
npx trigger.dev@latest deploy --dry-run