Open
Description
Is there an existing issue for this?
- I have searched the existing issues
Current behavior
When using the default HMR example EADDRINUSE
errors can occur, likely because close()
is not awaited.
Maybe the example should look something like this instead:
import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
async function bootstrap() {
if (module.hot?.data?.closePromise) {
await module.hot.data.closePromise;
module.hot.data.closePromise = null;
}
const app = await NestFactory.create(AppModule, {
forceCloseConnections: !!module.hot,
});
if (module.hot) {
module.hot.accept();
module.hot.dispose((data) => data.closePromise = app.close());
}
await app.listen(3000);
}
bootstrap();
Minimum reproduction code
https://docs.nestjs.com/recipes/hot-reload
In which operating systems have you tested?
- macOS
- Windows
- Linux