I'm hitting the same bug as https://github.com/nestjs/bull/issues/453 in 2024 using bullmq and redis.
up to date packages:
"@nestjs/bullmq": "^11.0.2",
"bullmq": "^5.41.8",
"ioredis": "^5.6.0",
app module has those imports:
BullModule.forRootAsync({
imports: [ConfigModule.forFeature(AppConfig)],
inject: [AppConfig],
useFactory: async ({ env }: ConfigService<AppConfig>) => ({
connection: {
url: env.REDIS_URL,
},
}),
}),
BullModule.registerQueue({
name: QUEUE,
}),
and nothing else specifically configured afterwards. the worker is built like this:
export class AppWorker extends Worker<Payload> {
constructor(
@InjectQueue(QUEUE) queue: Queue,
private appService: AppService,
) {
super(QUEUE, null, {
autorun: false,
connection: queue.opts.connection,
})
}
}
the queue.opts.connection logs the same as the env.REDIS_URL, so it prooves that the queue is properly set according to the forRootAsync and the worker is using it, so the 3 items of that setup are actually using the same connection object afaik. still i have 2 connections made:
Error: getaddrinfo ENOTFOUND not-redis
at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:109:26) {
errno: -3008,
code: 'ENOTFOUND',
syscall: 'getaddrinfo',
hostname: 'not-redis' // <- env.REDIS_URL, container turned off for debugging
}
Error: connect ECONNREFUSED 127.0.0.1:6379
at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1610:16) {
errno: -61,
code: 'ECONNREFUSED',
syscall: 'connect',
address: '127.0.0.1', // <- what is responsible for this and how do i turn it off
port: 6379
}
there's no callstack, no debugging at all. kind of mysterious and annoying. any idea/pointers which would avoid me poking node_modules with console.log every 3 lines?