nest
nest copied to clipboard
DevTools - NestJS App will not start and no error is given if DevTools Port in use by another NestJS App
Is there an existing issue that is already proposing this?
- [X] I have searched the existing issues
Is your feature request related to a problem? Please describe it
I lost a day trying to debug why only one of my two (dev and stage) NestJS apps would start at the same time on my server. In this release I had also added socket.io and believed it was the cause - it was not.
I had recently installed NestJS DevTools with the default configuration and did not specify a port. As a result both apps defaulted to port 8000. However, the second app will not start ( node dist/main.js ) - it does not output any Error or Info and the typical first terminal line for NestJS does not appear:
This line does not even display in terminal: INFO [2024-09-05 12:09:25.053 +1000] (Nesula@Pino: /97304): Starting Nest application... {"context":"NestFactory"}
Describe the solution you'd like
In the DevTools Documentations update to show port value with a note:
@Module({
imports: [
DevtoolsModule.register({
http: process.env.NODE_ENV !== 'production'
port: 8000 /* Port must be unique amongst NestJS instances on same server */
}),
],
controllers: [AppController],
providers: [AppService]
})
export class AppModule {}
It would also be helpful to include async to allow use of the Nest configService:
DevtoolsModule.registerAsync({ /* ASYNCHRONOUS CONFIGURATION */
imports: [ConfigModule],
inject: [ConfigService],
useFactory: async (configService: ConfigService) => ({
http: configService.get('devtools.enabled'), /* Enable HTTP Devtools in development and stage environments */
port: configService.get('devtools.port'), /* Port must be unique amongst NestJS instances on same server */
}),
}),
Also, would it be possible to output to the terminal if the port is already in use or something that tells the user it is a DevTools related issue? I had completely forgotten I had installed DevTools and not yet deployed to stage app.
Teachability, documentation, adoption, migration strategy
See above for documentation update.
What is the motivation / use case for changing the behavior?
These reasons:
- To prevent users spending development time debugging why app will not start without error to help.
- Improve installation experience of NestJS DevTools
- To make it easier to use NestJS configService in DevTools config.