Skip to main content
This section provides hints and solutions for common errors you might encounter when using BullMQ.

Missing Locks

Error Message

What It Means

This error occurs when a job being processed by a worker unexpectedly loses its “lock.”
When a worker processes a job, it requires a special lock key to ensure the job is currently “owned” by that worker. This prevents other workers from picking up the same job.
However, this lock can be deleted, and the deletion may not be detected until the worker tries to move the job to completed or failed status.

Common Causes

Problem: The worker is consuming too much CPU and has no time to renew the lock every 30 seconds (default expiration time).Solution:
  • Reduce worker concurrency
  • Optimize job processing code
  • Move CPU-intensive work to separate processes
  • Monitor worker CPU usage
Problem: The worker lost communication with Redis and cannot renew the lock in time.Solution:
  • Check network stability between worker and Redis
  • Implement proper connection retry logic
  • Monitor Redis connection health
  • Consider increasing lock renewal interval
Problem: The job was forcefully removed using BullMQ’s APIs or by removing the entire queue.Solution:
  • Avoid removing jobs that are currently being processed
  • Use proper job state checks before removal
  • Implement graceful job cancellation
Problem: Redis instance has wrong maxmemory-policy setting. It should be noeviction to avoid Redis removing lock keys before expiration.Solution:
This is a critical configuration. Without noeviction, Redis may remove lock keys, causing jobs to lose their locks.

Invalid or Undefined Environment Variables

Error Message

What It Means

This error typically happens when a parameter passed into a Redis command ends up being something other than a valid string or number.

Common Causes

If you rely on environment variables (e.g., for queue names or job data), this error can occur when those variables are:
  • Undefined (not set at all)
  • Empty strings (i.e., "")
  • Non-string values (e.g., objects or arrays)

Solutions

1

Validate Environment Variables Early

Check all required environment variables during initialization:
This ensures you fail fast if a variable isn’t set, instead of causing hidden Lua script errors.
2

Use TypeScript Strictness

Enable strictNullChecks and explicitly type environment variables:
3

Provide Defaults Where Appropriate

Use fallback values when appropriate:
Be sure fallback values are actually valid in your production workflow.

Example: Robust Configuration

Job Stuck in Active State

Symptoms

  • Jobs remain in “active” state indefinitely
  • Jobs are not being processed
  • No error messages in logs

Solutions

Ensure workers are running and connected:
Make sure job processors complete or throw errors:
Jobs should automatically become stalled after 30 seconds. Check stalled jobs:

Memory Issues

Symptoms

  • Redis running out of memory
  • Jobs disappearing
  • “OOM command not allowed” errors

Solutions

1

Configure maxmemory-policy

2

Enable job auto-removal

3

Increase Redis memory

4

Monitor job data size

Keep job data small - store large data elsewhere:

Connection Issues

Symptoms

  • “ECONNREFUSED” errors
  • Workers not picking up jobs
  • Intermittent failures

Solutions

Performance Issues

Jobs Processing Slowly

Increase Concurrency

Add More Workers

Scale horizontally by running multiple worker instances

Optimize Job Processing

Profile and optimize slow job processors

Use Redis Cluster

Distribute load across multiple Redis nodes

Debugging Tips

1

Enable debug logging

2

Check job state

3

Inspect Redis directly

Going to Production

Production deployment best practices

Redis Configuration

Redis compatibility and configuration