Skip to main content

Background Jobs

Cron jobs trigger API routes to process queued operations and scheduled tasks.
Terra has two types of background processing:
  1. Queue Processor — Processes async operations (webhooks, emails, Airtable syncs)
  2. Lifecycle Worker — Handles scheduled form lifecycle events (auto-publish, auto-close)

Queue Processor

The queue processor handles async operations that were enqueued during form submission.

Operation Types


Lifecycle Worker

The lifecycle worker handles scheduled form events and cleanup tasks.

Task Breakdown

Scheduled Publishing

Forms can be scheduled to publish automatically:

Form Auto-Freezing

Forms are automatically frozen after receiving their first submission:

Cron Configuration

Both workers are triggered via Vercel Cron Jobs:

API Endpoints


Monitoring

Queue Health

Worker Health

The worker returns detailed results:
Check logs for worker activity:

Error Handling

Both workers handle errors gracefully:
  1. Per-item isolation: One failed operation doesn’t block others
  2. Logging: All errors are logged with context
  3. Retry logic: Queue operations retry with exponential backoff
  4. Dead letter: Persistently failing operations are marked as failed

Local Development

For local testing, you can trigger workers manually:
Or run the worker loop directly:

Queue Architecture

How the async queue works

Webhooks

Webhook delivery system