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

fix(microservices): cleanup unary call on unsubscribe #10288

Merged
merged 1 commit into from Sep 19, 2022

Conversation

szilveszterandras
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?

For grpc unary requests, if the consumer unsubscribes from the Observable before the unary response arrives, the call isn't cancelled, as opposed to a streaming endpoint, which does handle client-side unsubscribes. This is a problem in high-performance grpc applications, where we may build timeout/retry logic into demanding endpoints, such as long-running db queries. Retried but not closed upstream calls can lead to unnecessary cpu load, network overhead, etc.

I provided a minimal reproduction example here: https://github.com/szilveszterandras/nest-unary

Issue Number: N/A

What is the new behavior?

If a subscriber unsubscribes from the Observable coming out of a unary request, the grpc call is cancelled.

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

@coveralls
Copy link

Pull Request Test Coverage Report for Build 7693fc3d-16d8-485b-83dd-adb7b7a513fb

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

Totals Coverage Status
Change from base Build 33d64ea6-8564-4074-89ae-b787d2d45c2d: 0.003%
Covered Lines: 6103
Relevant Lines: 6505

💛 - Coveralls

@kamilmysliwiec
Copy link
Member

lgtm

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