Skip to main content

Overview

Throw DelayedError from a job processor to move the job back to the delayed state, scheduling it for future processing.

Class

Usage

Examples

Waiting for Dependencies

Time-Based Conditions

Resource Availability

External Service Status

Behavior

When DelayedError is thrown:
  1. The job is moved from active to delayed state
  2. The job will be picked up again after the delay period
  3. The job’s attemptsMade counter is not incremented
  4. The job will be retried indefinitely until it succeeds or throws a different error

Setting Delay Duration

The delay duration is determined by the job’s existing delay settings. To control the delay:
Or change the delay dynamically:

Comparison with Other Approaches

DelayedError vs Regular Error

DelayedError vs Manual Delay

Infinite Delay Protection

Be careful with DelayedError to avoid infinite loops:

Monitoring Delayed Jobs

When to Use DelayedError

Use DelayedError when:
  • Waiting for external dependencies to become available
  • Waiting for specific time conditions
  • Resources are temporarily unavailable
  • External services are temporarily down
  • Data is being processed by another job
Don’t use DelayedError for:
  • Validation errors - use UnrecoverableError
  • Rate limiting - use RateLimitError
  • Permanent failures - throw regular Error or UnrecoverableError
  • Normal retry logic - use job attempts and backoff