[Bug] NestJS integration, app/worker hot reloading error
I'm using nestjs-temporal package, but I assume it would be the same with the nestjs typescript samples provided(if using nest start worker --watch). Everything is good at first run, but after code changes and nestjs reloading, the worker cannot restart, saying address port is already in use(3000). Does anyone experienced this? Any ideas of a workaround would be appreciated. Manually restarting app is quite annoying.
Maybe to answer my question, I found one possible alternative We can split a nestjs app, by creating a separate entry point and main module that would create standalone app(no http server). Then, edit the nest-cli.json to register this as a separate app. Code and modules can still be shared.
import { NestFactory } from '@nestjs/core';
import { MainRuntimeModule } from './runtime.module';
async function bootstrap() {
await NestFactory.createApplicationContext(MainRuntimeModule);
}
bootstrap();
We load the module that registers workers only here + everything you need from the main codebase.
Does the tip mentioned in https://github.com/KurtzL/nestjs-temporal/issues/54#issuecomment-2179000500 fixes this problem for you? (Adding app.enableShutdownHooks()) It does to me.
Is the Temporal SDK itself playing any role in this?
I'd be inclined to close this ticket as non-actionable from our side.
It's been a while since I looked into this. It might have been fixed. From what I recall, I got to a satisfactory solution, maybe by using the tips mentioned here. And anyways, it was something happening in development. I would say this can be closed from my side.