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

DevTools - NestJS App will not start and no error is given if DevTools Port in use by another NestJS App #13945

Closed
1 task done
julian-iFactory opened this issue Sep 5, 2024 · 1 comment

Comments

@julian-iFactory
Copy link

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

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:

  1. To prevent users spending development time debugging why app will not start without error to help.
  2. Improve installation experience of NestJS DevTools
  3. To make it easier to use NestJS configService in DevTools config.
@julian-iFactory julian-iFactory added needs triage This issue has not been looked into type: enhancement 🐺 labels Sep 5, 2024
@kamilmysliwiec
Copy link
Member

I can't reproduce your issue - the error shows up in my terminal (when the port is already taken)

image

@micalevisk micalevisk removed the needs triage This issue has not been looked into label Nov 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants