#4595·bullmq

[Bug]: ioredis v6 `RedisOptions` not assignable to bullmq v6 `ConnectionOptions`

Author: TiBianModCreated Aug 20, 2026Updated Sep 23, 2026
Labelsbug

Version

6.1.2

Platform

NodeJS

What happened?

Passing an ioredis 6 RedisOptions object to a BullMQ ConnectionOptions (used by Queue, FlowProducer, etc.) fails to type-check. ioredis 6 widened its retryStrategy type to accept null, but BullMQ's own RedisOptions/ConnectionOptions does not, so a valid ioredis options object is not assignable to BullMQ's connection type.

How to reproduce.

typescript
import type { RedisOptions } from "ioredis";
import type { ConnectionOptions } from "bullmq";

// Typical flow: share an ioredis RedisOptions config with BullMQ
function connection(opts: RedisOptions): ConnectionOptions {
    return { ...opts, keyPrefix: undefined };
}

Expected: type-checks cleanly — BullMQ's docs state that "the options you pass to BullMQ are passed to the ioredis constructor", so an ioredis RedisOptions should be accepted as a ConnectionOptions.

Actual error:

TS2322: Type '{ ...; retryStrategy?: RetryStrategy; ... }' is not assignable to type 'ConnectionOptions'.
  Type '{ ... }' is not assignable to type 'RedisOptions'.
    Types of property 'retryStrategy' are incompatible.
      Type 'RetryStrategy' is not assignable to type '((times: number) => void | number | null) | undefined'.
        Type 'null' is not assignable to type '((times: number) => void | number | null) | undefined'.

Root cause — the type divergence on retryStrategy:

  • ioredis 6 (node_modules/ioredis/built/redis/RedisOptions.d.ts):

    typescript
    export type RetryStrategy = ((times: number) => number | void | null) | null | undefined;
    
    interface CommonRedisOptions extends CommanderOptions {
        retryStrategy?: RetryStrategy;
    }
    
    export type RedisOptions = CommonRedisOptions &
        SentinelConnectionOptions &
        StandaloneConnectionOptions;

    ioredis 6 explicitly allows retryStrategy: null (a documented way to stop reconnect retries).

  • BullMQ (node_modules/bullmq/dist/esm/interfaces/redis-options.d.ts):

    typescript
    export interface RedisOptions extends BaseOptions {
        retryStrategy?: (times: number) => number | void | null;
        [key: string]: any;
    }
    
    export type ConnectionOptions =
        RedisOptions | ClusterOptions | IRedisClient | RedisConnectionClient;

    BullMQ's retryStrategy does not include null in its union, so the ioredis 6 type (which can be null) is not assignable. The [key: string]: any index signature does not rescue this, because retryStrategy is explicitly declared in both types, so the intersection check on that named property wins.

Relevant log output

bash
error TS2322: Type '{ port?: number | undefined; host?: string | undefined; ... retryStrategy?: RetryStrategy; ... }' is not assignable to type 'ConnectionOptions'.
  Type '{ ... }' is not assignable to type 'RedisOptions'.
    Types of property 'retryStrategy' are incompatible.
      Type 'RetryStrategy' is not assignable to type '((times: number) => void | number | null) | undefined'.
        Type 'null' is not assignable to type '((times: number) => void | number | null) | undefined'.

Code of Conduct

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