Skip to content

feat(@nestjs/graphql): add stopOnApplicationShutdown option for graceful shutdown#3889

Open
dgfh0450 wants to merge 1 commit intonestjs:masterfrom
dgfh0450:feat/stop-on-application-shutdown
Open

feat(@nestjs/graphql): add stopOnApplicationShutdown option for graceful shutdown#3889
dgfh0450 wants to merge 1 commit intonestjs:masterfrom
dgfh0450:feat/stop-on-application-shutdown

Conversation

@dgfh0450
Copy link
Copy Markdown

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Other... Please describe:

What is the current behavior?

GraphQL server stops in onModuleDestroy lifecycle hook, which is called before beforeApplicationShutdown. This prevents users from implementing graceful shutdown logic because the server is already closed when beforeApplicationShutdown is triggered.

Issue Number: #3597

What is the new behavior?

Added stopOnApplicationShutdown option to GqlModuleOptions. When set to true, the GraphQL server stops in onApplicationShutdown instead of onModuleDestroy, allowing the server to keep accepting requests during beforeApplicationShutdown for graceful shutdown handling.

Default is false to preserve existing behavior.

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

As suggested by @kamilmysliwiec in #3597, this adds a configuration attribute to control the shutdown behavior without introducing a breaking change.

…ful shutdown

Allow users to defer GraphQL server shutdown from onModuleDestroy to
onApplicationShutdown by setting stopOnApplicationShutdown to true.
This enables graceful shutdown logic in beforeApplicationShutdown
while the server is still accepting requests.

Closes nestjs#3597

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant