AlariCode / nestjs-rmq

A custom library for NestJS microservice. It allows you to use RabbitMQ or AMQP.
https://purpleschool.ru
MIT License
285 stars 38 forks source link

callback is not a function #2

Closed i-kitaev closed 5 years ago

i-kitaev commented 5 years ago

Hello, i have this exception.

Unhandled rejection TypeError: callback is not a function on https://github.com/AlariCode/nestjs-rmq/blob/8b576be1d441f087b6ba1f19390e43bfe35c9cfe/lib/server/server.ts#L50

I used packages: "@nestjs/core": "5.3.6", "@nestjs/common": "5.3.6", "nestjs-rmq": "0.1.1"

AlariCode commented 5 years ago

@Vnkitaev, thanks for report, I'll check with latest version of NestJS.

AlariCode commented 5 years ago

@Vnkitaev, tested with:

"dependencies": {
    "@nestjs/common": "^5.3.6",
    "@nestjs/core": "^5.3.6",
    "@nestjs/microservices": "^5.3.6",
    "@nestjs/testing": "^5.0.0",
    "@nestjs/websockets": "^5.0.0",
    "nestjs-rmq": "0.1.1"
  },

No error. Everything seams fine.

Could you provide actual code, that causes this error?

i-kitaev commented 5 years ago
await NestFactory.createMicroservice(ApplicationModule, {
      strategy: new ServerRMQ({
        urls: ['amqp://guest:guest@localhost:5672'],
        queue: 'test',
        queueOptions: { durable: false }
      })
    });

await this.app.listen(3000);

ApplicationModule is empty.

2018-09-11 22 18 40 2018-09-11 22 19 40

If the callback is optional, maybe add check is callback a function? https://github.com/AlariCode/nestjs-rmq/blob/8b576be1d441f087b6ba1f19390e43bfe35c9cfe/lib/server/server.ts#L41

AlariCode commented 5 years ago

@Vnkitaev, I updated package to 0.1.2 and added additional check if callback is a function. Now your error must be gone. But NestJS insists, that callback must be a function. Even if I set it to number, listen() still warn about error:

image

When you start microservice you don't specify any port: https://docs.nestjs.com/microservices/basics

import { NestFactory } from '@nestjs/core';
import { Transport } from '@nestjs/microservices';
import { ApplicationModule } from './app.module';

async function bootstrap() {
  const app = await NestFactory.createMicroservice(ApplicationModule, {
    transport: Transport.TCP,
  });
  app.listen(() => console.log('Microservice is listening'));
}
bootstrap();

But additional check will be ok) Thanks for submitting an issue 👍

i-kitaev commented 5 years ago

Thanks your :)