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): support client cancel grpc request in unary stream #12026

Merged
merged 4 commits into from
Jul 17, 2023

Conversation

tanhv90
Copy link
Contributor

@tanhv90 tanhv90 commented Jul 14, 2023

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?

Unsubscribe unary request with client upstream do nothing:

  • Not cancel grpc call
  • Request keep connection

Issue Number: #12023

What is the new behavior?

When unsubscribe unary request with client upstream:

  • Check grpc call is finished or not
  • If not, call call.cancel() to cancel request & release resource

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

@coveralls
Copy link

coveralls commented Jul 14, 2023

Pull Request Test Coverage Report for Build 2e139aca-bd85-405b-b32b-ed5ca31697ba

  • 4 of 8 (50.0%) changed or added relevant lines in 1 file are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage decreased (-0.05%) to 92.814%

Changes Missing Coverage Covered Lines Changed/Added Lines %
packages/microservices/client/client-grpc.ts 4 8 50.0%
Files with Coverage Reduction New Missed Lines %
packages/microservices/client/client-grpc.ts 1 79.47%
Totals Coverage Status
Change from base Build 3dfb6545-1975-4a99-b2ed-aaa49f412a91: -0.05%
Covered Lines: 6368
Relevant Lines: 6861

💛 - Coveralls

return;
}
}
return observer.error(this.serializeError(error));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: formatting is broken?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you. Just commit the fix.

afterEach(() => {
// invoke client callback to allow resources to be cleaned up
clientCallback(null, {});
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this hook was removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you. Just commit the fix.

@tanhv90
Copy link
Contributor Author

tanhv90 commented Jul 14, 2023

@kamilmysliwiec please help check the fix

@kamilmysliwiec kamilmysliwiec merged commit dba6fa4 into nestjs:master Jul 17, 2023
2 checks passed
@tanhv90 tanhv90 deleted the fix-grpc-client-cannot-cancel branch July 17, 2023 10:29
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.

3 participants