Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Double events when using microservice #1393

Open
2 of 4 tasks
ivcosla opened this issue Jun 15, 2023 · 2 comments
Open
2 of 4 tasks

Double events when using microservice #1393

ivcosla opened this issue Jun 15, 2023 · 2 comments
Labels

Comments

@ivcosla
Copy link

ivcosla commented Jun 15, 2023

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

When NestFactory is used to build a microservice app, and then init is called for it, any attempt to send a message through the EventBus will result in the EventsListener's being called twice with the event.

Minimum reproduction code

https://gist.github.com/ivcosla/908e717af746801787cced1f80c1c327

Steps to reproduce

  1. Copy/paste the shared gist into any project.
  2. Run the test.

Expected behavior

The EventsHandler's for the emitted event should be called only once.

Package version

10.0.0

NestJS version

10.0.0

Node.js version

20.3.0

In which operating systems have you tested?

  • macOS
  • Windows
  • Linux

Other

No response

@ivcosla ivcosla added the bug label Jun 15, 2023
@ivcosla
Copy link
Author

ivcosla commented Jun 16, 2023

If I comment this line: https://github.com/nestjs/nest/blob/master/packages/microservices/nest-microservice.ts#LL159C13-L159C13 the event is emitted only once.

@ivcosla
Copy link
Author

ivcosla commented Jun 16, 2023

NestApplication doesn't calls super.init() inside it's init() method, whereas NestMicroservice does. Maybe is that it?.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant