taskforcesh / bullmq

BullMQ - Message Queue and Batch processing for NodeJS and Python based on Redis
https://bullmq.io
MIT License
5.98k stars 387 forks source link

[Bug]: ERR_SOCKER_BAD_PORT #2792

Closed anapeksha closed 24 minutes ago

anapeksha commented 3 hours ago

Version

v5.13.2

Platform

NodeJS

What happened?

I am receiving an error,

RangeError [ERR_SOCKET_BAD_PORT]: Port should be >= 0 and < 65536. Received type number (NaN). at lookupAndConnect (node:net:1298:5) at Socket.connect (node:net:1255:5) at connect (node:net:238:17)

Even though I can see the port exists and tried logging the PORT, it works.

Not sure, why this error is being thrown

How to reproduce.

Try integrating @nestjs/bullmq and bullmq in a bullmq project.

import { BullModule } from "@nestjs/bullmq";
import { Module } from "@nestjs/common";
import { MailQueueProcessor } from "./mail.processor";

@Module({
  imports: [
    BullModule.forRoot({
      connection: {
        host: process.env.REDIS_HOST,
        port: parseInt(process.env.REDIS_PORT, 10),
        password: process.env.REDIS_PASSWORD || undefined,
      },
    }),
    BullModule.registerQueue({
      name: "mail",
    }),
  ],
  providers: [MailQueueProcessor],
  exports: [BullModule],
})
export class QueueModule {}

Relevant log output

RangeError [ERR_SOCKET_BAD_PORT]: Port should be >= 0 and < 65536. Received type number (NaN).
    at lookupAndConnect (node:net:1298:5)
    at Socket.connect (node:net:1255:5)
    at connect (node:net:238:17)
    at /Users/test/Documents/test/node_modules/ioredis/built/connectors/StandaloneConnector.js:54:66
    at process.processTicksAndRejections (node:internal/process/task_queues:77:11) {
  code: 'ERR_SOCKET_BAD_PORT'
}

Code of Conduct

roggervalf commented 2 hours ago

looks like the error is coming from ioredis. Also could be related with nest/bullmq package on how it's passing that option

anapeksha commented 24 minutes ago

Yes right! But couldn't find anything relevant in the ioredis codebase. Will raise one issue with @nestjs/bullmq too.