Overview
Throw RateLimitError from a job processor to indicate that the job should be retried later due to rate limiting.Class
Creating Rate Limit Errors
Use the static method on the Worker class:Usage
Examples
API Rate Limiting
Custom Rate Limiter
Service-Specific Rate Limits
Token Bucket Algorithm
Behavior
When RateLimitError is thrown:- The job is moved back to the
waitstate - A rate limit TTL is set on the queue
- Workers will wait before fetching new jobs
- The job’s
attemptsMadecounter is not incremented - The job will be retried when the rate limit expires
Global Rate Limiting
Set a global rate limit on the queue:Worker-Level Rate Limiting
Combining with Other Limits
Monitoring Rate Limits
Dynamic Rate Limits
When to Use RateLimitError
Use RateLimitError when:- External API returns 429 (Too Many Requests)
- Internal rate limits are exceeded
- Service quota limits are reached
- Need to throttle job processing
- Protecting downstream services
- Validation errors - use UnrecoverableError
- Temporary delays - use DelayedError
- Normal retry logic - use job attempts
- Permanent failures - throw regular Error
Related
- UnrecoverableError - Fail job immediately
- DelayedError - Delay job processing
- Worker - Worker rate limiter options
- Queue - Global rate limit methods
