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

onApplicationBootstrap hook does not start in the hybrid microservice #8446

Closed
6 of 15 tasks
inmativ opened this issue Oct 26, 2021 · 1 comment
Closed
6 of 15 tasks
Labels
needs triage This issue has not been looked into

Comments

@inmativ
Copy link

inmativ commented Oct 26, 2021

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

For some reason, the onApplicationBootstrap hook does not start in the hybrid microservice. It runs in a regular app and in a regular microservice, but not in a hybrid one. Tried with inheritAppConfig: true and false too.

Minimum reproduction code

https://github.com/benefactor1/nestjs-cron-demo

Expected behavior

run onApplicationBootstrap in hybrid MS.

Package

  • I don't know. Or some 3rd-party package
  • @nestjs/common
  • @nestjs/core
  • @nestjs/microservices
  • @nestjs/platform-express
  • @nestjs/platform-fastify
  • @nestjs/platform-socket.io
  • @nestjs/platform-ws
  • @nestjs/testing
  • @nestjs/websockets
  • Other (see below)

NestJS version

8

Packages versions

see repository

Node.js version

14

In which operating systems have you tested?

  • macOS
  • Windows
  • Linux
@inmativ inmativ added the needs triage This issue has not been looked into label Oct 26, 2021
@kamilmysliwiec
Copy link
Member

Change this:

const app = await NestFactory.create(HybridModule);

const cronDemoMS = app.connectMicroservice<MicroserviceOptions>(
  {
    transport: Transport.GRPC,
    options: {
      url: `${host}:${port}`,
      package: CRON_DEMO_PACKAGE_NAME,
      protoPath: 'apps/libs/proto/cron-demo.proto',
      loader: loaderConfig,
    },
  },
  { inheritAppConfig: true },
);

await cronDemoMS.listen();

to this:

const app = await NestFactory.create(HybridModule);
app.connectMicroservice<MicroserviceOptions>(
  {
    transport: Transport.GRPC,
    options: {
      url: `${host}:${port}`,
      package: CRON_DEMO_PACKAGE_NAME,
      protoPath: 'apps/libs/proto/cron-demo.proto',
      loader: loaderConfig,
    },
  },
  { inheritAppConfig: true },
);

// new
// vvvvv
await app.startAllMicroservices()

// note "app" here instead of "cronDemoMS"
// vvvvv 
await app.listen();

Please, use our Discord channel (support) for such questions. We are using GitHub to track bugs, feature requests, and potential improvements.

@nestjs nestjs locked and limited conversation to collaborators Oct 26, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
needs triage This issue has not been looked into
Projects
None yet
Development

No branches or pull requests

2 participants