You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is there an existing issue that is already proposing this?
I have searched the existing issues
Is your feature request related to a problem? Please describe it
some of the users of my NestJS gRPC Reflection Module package have reported confusing behavior where the module is not properly initialized when running within their Hybrid Application. The issue boils down to the fact that the app.startAllMicroservices method will start all of the connected microservices and properly serve requests but will not run the module lifecycle hooks. Lifecycle hooks are only run when app.listen is called, however not all users will be running an HTTP server in their application and may omit that
when searching through the issues in this repo it seems like similar confusion has come up before in nestjs/nest#12042 and nestjs/nest#8446. I'm not 100% sure of what solution would make the most sense here so I've added a couple thoughts to start a discussion below
Describe the solution you'd like
the main pitfall here seems to be when a users hybrid application does not use an HTTP server. The Hybrid Application documentation is geared towards a "microservice + HTTP server" scenario, however users may also be running multiple multiple microservices instead without any HTTP server in which case they are not going to use the app.listen call and are not likely to know that they'd need to call app.init manually
Option 1: the simplest solution to this seems like it would be to make the app.startAllMicroservices method run the module lifecycle hooks if they haven't been run already so that the app.listen or app.init calls are no longer necessary. This would also make the microservice startup better match the behavior of the HTTP service startup
Option 2: alternatively we could combine the microservice startup logic into app.listen so that there isn't that distinction in the first place. This would likely require a method override so that the port number wouldn't be required in app.listen
Option 3: we could add a warning to the hybrid application docs to be clear that the app.init or app.listenmust be called at some point in the application when using startAllMicroservices
What is the motivation / use case for changing the behavior?
avoiding confusing scenarios where the application successfully starts up and can serve requests but none of the module lifecycle hooks have run, causing incomplete module configuration
The text was updated successfully, but these errors were encountered:
Option 3: we could add a warning to the hybrid application docs to be clear that the app.init or app.listen must be called at some point in the application when using startAllMicroservices
Let's do this. Would you like to contribute and create a PR to the docs?
Is there an existing issue that is already proposing this?
Is your feature request related to a problem? Please describe it
some of the users of my NestJS gRPC Reflection Module package have reported confusing behavior where the module is not properly initialized when running within their Hybrid Application. The issue boils down to the fact that the
app.startAllMicroservices
method will start all of the connected microservices and properly serve requests but will not run the module lifecycle hooks. Lifecycle hooks are only run whenapp.listen
is called, however not all users will be running an HTTP server in their application and may omit thatwhen searching through the issues in this repo it seems like similar confusion has come up before in nestjs/nest#12042 and nestjs/nest#8446. I'm not 100% sure of what solution would make the most sense here so I've added a couple thoughts to start a discussion below
Describe the solution you'd like
the main pitfall here seems to be when a users hybrid application does not use an HTTP server. The Hybrid Application documentation is geared towards a "microservice + HTTP server" scenario, however users may also be running multiple multiple microservices instead without any HTTP server in which case they are not going to use the
app.listen
call and are not likely to know that they'd need to callapp.init
manuallyOption 1: the simplest solution to this seems like it would be to make the
app.startAllMicroservices
method run the module lifecycle hooks if they haven't been run already so that theapp.listen
orapp.init
calls are no longer necessary. This would also make the microservice startup better match the behavior of the HTTP service startupOption 2: alternatively we could combine the microservice startup logic into
app.listen
so that there isn't that distinction in the first place. This would likely require a method override so that the port number wouldn't be required inapp.listen
Option 3: we could add a warning to the hybrid application docs to be clear that the
app.init
orapp.listen
must be called at some point in the application when usingstartAllMicroservices
Teachability, documentation, adoption, migration strategy
will update this section after discussion
What is the motivation / use case for changing the behavior?
avoiding confusing scenarios where the application successfully starts up and can serve requests but none of the module lifecycle hooks have run, causing incomplete module configuration
The text was updated successfully, but these errors were encountered: