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:- The job is moved from
activetodelayedstate - The job will be picked up again after the delay period
- The job’s
attemptsMadecounter is not incremented - 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: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
- Validation errors - use UnrecoverableError
- Rate limiting - use RateLimitError
- Permanent failures - throw regular Error or UnrecoverableError
- Normal retry logic - use job attempts and backoff
Related
- UnrecoverableError - Fail job immediately
- RateLimitError - Rate limiting
- WaitingChildrenError - Wait for child jobs
- Job.changeDelay() - Change job delay programmatically
