Closed sjacq closed 5 months ago
I guess it's up to you to change the default port (8000), as you've done here:
I guess that's up to you to change the default port (8000), as you did already here
Even if you change the port, it will still try to allocate it twice.
randomInt(8000, 8999)
, you'll see in the console that 2 ports are allocated.Obvisouly, we'd like only one port, so we know which one and can use it in the devtools portal.
got it
not sure what is the desired nor the best behavior but I see that that happens because you're using the same root module (AppModule
) twice, and so the dev tools module
Devtools should start only once for the NestJS App.
I believe that we shouldn't follow this rule because you can have one devtools module for each app just fine. Also, those nestjs apps created by the factory are decoupled. So initializing the devtools module once doesn't feels right
My bad ! Stupid mistake.
Trying to set up a hybrid application, so microservice should have been defined using app.connectMicroservice({})
and not createMicroservice
, which as you pointed out injects twice the app.module.ts
Sorry about that. Case closed.
Thanks for the reactivity.
Is there an existing issue for this?
Current behavior
When an app is set to serve as a microservice as well, Devtools tries to allocate / use the port twice, preventing the app from starting.
Minimum reproduction code
https://stackblitz.com/edit/nestjs-typescript-starter-gzpmcr?file=src%2Fmain.ts
Steps to reproduce
Display the browser console and start the StackBlitz demo.
If you replace the return 8000 by a random integer (eg between 8000 and 8999) you'll see the 2 ports allocated.
Expected behavior
Devtools should start only once for the NestJS App.
Package
Other package
NestJS Devtools
NestJS version
10.3.8
Packages versions
Node.js version
21.7.3
In which operating systems have you tested?
Other
No response