feat(@nestjs/graphql): add stopOnApplicationShutdown option for graceful shutdown#3889
Open
dgfh0450 wants to merge 1 commit intonestjs:masterfrom
Open
feat(@nestjs/graphql): add stopOnApplicationShutdown option for graceful shutdown#3889dgfh0450 wants to merge 1 commit intonestjs:masterfrom
dgfh0450 wants to merge 1 commit intonestjs:masterfrom
Conversation
…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>
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
GraphQL server stops in
onModuleDestroylifecycle hook, which is called beforebeforeApplicationShutdown. This prevents users from implementing graceful shutdown logic because the server is already closed whenbeforeApplicationShutdownis triggered.Issue Number: #3597
What is the new behavior?
Added
stopOnApplicationShutdownoption toGqlModuleOptions. When set totrue, the GraphQL server stops inonApplicationShutdowninstead ofonModuleDestroy, allowing the server to keep accepting requests duringbeforeApplicationShutdownfor graceful shutdown handling.Default is
falseto preserve existing behavior.Does this PR introduce a breaking change?
Other information
As suggested by @kamilmysliwiec in #3597, this adds a configuration attribute to control the shutdown behavior without introducing a breaking change.