Overview
This task sends an onboarding email sequence to a user. Each email is wrapped inretry.onThrow so
that only the failed send is retried — not the entire task. Between emails, wait.for suspends
the task for a configurable duration. During the wait, the task is fully paused and consumes zero
resources.
Task code
trigger/email-sequence.ts
Key concepts
wait.for — pause without consuming resources
Calling await wait.for({ days: 3 }) suspends the task entirely. No compute is used during the
wait. Once the duration elapses, the task resumes exactly where it left off.
retry.onThrow — retry a block, not the whole task
retry.onThrow wraps a code block with its own retry logic. If the block throws, only that block
is retried — any work already done outside the block (earlier emails in the sequence) is not
repeated.
Testing your task
To test this task in the Trigger.dev dashboard, use the following payload on the Test page:During testing, the
wait.for call will pause the task for the configured duration. If you want
to skip the wait in development, you can reduce the duration (e.g. { seconds: 5 }) while
testing and restore it before deploying.Related examples
OpenAI with retrying
Task-level retry configuration for OpenAI API calls
Puppeteer
Use Puppeteer to generate PDFs and scrape web pages