Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(microservices): allow grpc-server graceful shutdown #12014

Merged

Conversation

mathieubergeron
Copy link
Contributor

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?

The grpc-server always closes using forceShutdown(). That does not allow graceful shutdown of the application.

forceShutdown: Forcibly shuts down the server. The server will stop receiving new calls and cancel all pending calls.

Issue Number: #12005

What is the new behavior?

Added a gracefulShutdown option for gRPC. When set to true, grpc-server will use tryShutdown when closing instead of forceShutdown.

tryShutdown: Gracefully shuts down the server. The server will stop receiving new calls, and any pending calls will complete.

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

GrpcOptions is shared between server-grpc and client-grpc. So technically, it is possible to set gracefulShutdown even for the client. Unfortunately, graceful shutdown does not seem currently available for the client in grpc-js (see grpc/grpc-node#1340)

@coveralls
Copy link

Pull Request Test Coverage Report for Build 2308f034-fa12-4028-8f0f-6dc6fd2ab8e0

  • 8 of 8 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.008%) to 92.872%

Totals Coverage Status
Change from base Build c1539b00-4ddf-456c-973a-cfbbd4a2012d: 0.008%
Covered Lines: 6371
Relevant Lines: 6860

💛 - Coveralls

@kamilmysliwiec kamilmysliwiec merged commit d0bd92c into nestjs:master Jul 17, 2023
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants