Closed ssarj closed 3 years ago
Would you like to create a PR for this issue? The only suitable solution that I can see for now would be to set stopOnTerminationSignals
to false
by default.
Yep, will do. Thanks
Let's track this here https://github.com/nestjs/graphql/pull/1562
@kamilmysliwiec this issue needs to be re-opened as this is not working again (or still) when nestjs/graphql
is paired with platform-fastify
.
EDIT: I think this is broken again after the drain server plugin was set up globally because the drain plugin calls fastify.close()
- see this
EDIT 2: I think we should drop the drain plugins and implement connection draining in Nest in such a way that it gracefully shuts down the Express or Fastify server. Here's how Apollo Express Driver does it: https://github.com/apollographql/apollo-server/blob/main/packages/server/src/plugin/drainHttpServer/stoppable.ts
I'm submitting a...
Current behavior
Referenced repository contains a barebones
Nest
application that has:OnModuleDestroy
andOnApplicationShutdown
and logs when they're called (shutdown hooks are enabled)If I start the server and then kill it (either via CTRL+C, or sending
SIGTERM
) thenService.onModuleDestroy
is called, butService.onApplicationShutdown
never is. This appears to be due to the default behaviour ofGraphQLModule
/apollo-server-express
which also has Apollo listening to process signals. It then kills the process before Nest can shutdown gracefully.Expected behavior
That all lifecycle events are executed, and
Service.onApplicationShutdown
is called when shutdown hooks have been enabled in the Nest application, and the user isn't required to know that they have to turn off Apollo signal handling.Minimal reproduction of the problem with instructions
stopOnTerminationSignals
set tofalse
so executes the desired behaviourWhat is the motivation / use case for changing the behavior?
Environment