Skip to main content
@usenarrator/plugin-trigger-dev The Trigger.dev plugin reads a task as a named background job with its limits: how many attempts it gets and how long it waits between them, which queue and machine it runs on, and when it is stopped. Scheduled tasks turn their cron patterns into words with the time zone. Code that starts a task says whether it waits for the result, and lists options such as delays, tags and idempotency keys.
The plugin declares library: { name: "@trigger.dev/sdk", versions: ">=3 <5" } and reads v3 and v4, including imports from @trigger.dev/sdk/v3. It only narrates files that import the SDK or belong to a package that depends on it (see Dependency detection), and even then it leaves alone calls on objects that don’t come from the SDK, such as a jQuery trigger or a local array named runs.

Examples

A task with retries and hooks
English
A scheduled task
English
Triggering tasks
English
Tasks defined in the same file are recognized by their task(...) call. Tasks imported from elsewhere are recognized when their name ends in Task, as in sendWelcomeTask, or when they are triggered by ID through tasks.trigger.

What it covers

  • Tasks: task and schemaTask with retry, queue, machine and maxDuration, and the lifecycle hooks (onStartAttempt, onSuccess, onFailure, catchError and the rest).
  • Scheduled tasks: schedules.task with a cron pattern, time zone and environments, and the schedules API for creating and managing schedules.
  • Queues: queue() with its concurrency limit, and on-demand queues in v3.
  • Triggering: trigger, triggerAndWait and unwrap, batchTrigger and batch, tasks.trigger by ID, and options such as delay, ttl, tags, priority, concurrencyKey and idempotency keys.
  • Inside a run: wait.for, wait.until, wait tokens, retry.onThrow, AbortTaskRunError, run metadata (including the parent and root run’s), idempotencyKeys and runs.

Translating

The English phrasebook is exported as en and typed as TriggerPhrases. Its time section has the same shape as the other job plugins’ (TimePhrases).