[Bug]: ioredis v6 `RedisOptions` not assignable to bullmq v6 `ConnectionOptions`
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.
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):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):export interface RedisOptions extends BaseOptions { retryStrategy?: (times: number) => number | void | null; [key: string]: any; } export type ConnectionOptions = RedisOptions | ClusterOptions | IRedisClient | RedisConnectionClient;BullMQ's
retryStrategydoes not includenullin its union, so the ioredis 6 type (which can benull) is not assignable. The[key: string]: anyindex signature does not rescue this, becauseretryStrategyis explicitly declared in both types, so the intersection check on that named property wins.
Relevant log output
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
Source: taskforcesh/bullmq