Skip to content

[Bug]: Shared Redis connection objects cause job data to become empty and job names to become None #3401

Description

@cyucelen

Version

2.15.0

Platform

Python

What happened?

Summary

When sharing a Redis connection object between Queue and Worker instances in BullMQ Python, job data becomes empty ({}) and job names become None in the worker processor function. This breaks job processing functionality and causes applications to fail.

Environment

  • BullMQ Python version: 2.15.0
  • Python version: 3.13.6
  • Redis version: Latest
  • Operating System: macOS

Steps to Reproduce

  1. Create a shared Redis connection object using redis.asyncio.from_url()
  2. Pass this connection object to both Queue and Worker constructors
  3. Add a job with data to the queue
  4. Process the job with the worker

Expected Behavior

  • Job data should be preserved and accessible in the worker processor function
  • Job name should be preserved and accessible in the worker processor function
  • Shared connections should work as documented

Actual Behavior

  • Job data becomes an empty dictionary {}
  • Job name becomes None
  • Job processing fails due to missing data

Minimal Reproducible Example

import asyncio
import redis.asyncio as redis
from bullmq import Queue, Worker

async def demonstrate_bug():
    # Create shared Redis connection
    redis_client = redis.from_url('redis://localhost:6379')
    
    # Test data
    test_data = {'value': 42, 'message': 'test'}
    
    # Create queue with shared connection
    queue = Queue('test-queue', {'connection': redis_client})
    job = await queue.add('test-job', test_data)
    print(f"Job added with data: {job.data}")  # Shows correct data
    
    # Create worker with same shared connection
    async def processor(job, token):
        print(f"Worker received data: {job.data}")  # Shows empty {}
        print(f"Worker received name: {job.name}")   # Shows None
        return {'processed': True}
    
    worker = Worker('test-queue', processor, {'connection': redis_client})
    await asyncio.sleep(2)  # Wait for processing
    
    await worker.close()
    await redis_client.aclose()

# Run: asyncio.run(demonstrate_bug())

Workaround

Using Redis URL strings instead of shared connection objects works correctly:

# This works correctly
redis_url = 'redis://localhost:6379'
queue = Queue('test-queue', {'connection': redis_url})
worker = Worker('test-queue', processor, {'connection': redis_url})

How to reproduce.

No response

Relevant log output

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions