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

Feature/grpc cancellation #774

Merged
merged 5 commits into from Jun 21, 2018

Conversation

micmro
Copy link
Contributor

@micmro micmro commented Jun 8, 2018

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

[ ] Bugfix
[x] 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?

When a connected ClientGrpcProxy unsubscribes the Observable returned for an stream gRPC method the upstream connection stays untouched and the server continuous to send updates, even if no-one's listening.
Likewise the Observables complete is not getting called.

Issue Number: #773

What is the new behavior?

When the client cancels the ServerGrpc stops consuming it's Observable and the client's complete gets called.
Also:

  • all eventListener on call get cleaned up
  • Argument type of getService<T> got tighten, as it can only be a keyof T - get more help from the comiler

Does this PR introduce a breaking change?

[ ] Yes
[x] No

Other information

micmro and others added 3 commits June 8, 2018 15:21
- when client cancels the server stream gets completed too
- client introduced disconnection does not throw errors on the client side
- release client's event listener on 'end'
@coveralls
Copy link

coveralls commented Jun 8, 2018

Coverage Status

Coverage increased (+0.002%) to 94.963% when pulling 0c8e8fb on micmro:feature/grpc-cancellation into fed2459 on nestjs:master.

@micmro
Copy link
Contributor Author

micmro commented Jun 8, 2018

Will add more tests over the weekend.

@micmro micmro force-pushed the feature/grpc-cancellation branch 2 times, most recently from 58f3ca4 to 8058972 Compare June 10, 2018 21:31
@micmro micmro force-pushed the feature/grpc-cancellation branch from 8058972 to 0c8e8fb Compare June 10, 2018 21:40
@micmro
Copy link
Contributor Author

micmro commented Jun 11, 2018

Testing done. Should I squish the commits into one?

@PatrickEifler
Copy link

@micmro Thats a nice fix. @kamilmysliwiec Can we get this merged in.

@vdemidov230583
Copy link

@kamilmysliwiec That is an awesome feature, would be awesome to have that functionality in place. @kamilmysliwiec Could you please merge it? Waiting for a brighter future.

@@ -103,7 +105,9 @@ export class ServerGrpc extends Server implements CustomTransportStrategy {
return async (call, callback) => {
const handler = methodHandler(call.request, call.metadata);
const result$ = this.transformToObservable(await handler);
await result$.forEach(data => call.write(data));
await result$.pipe(
takeUntil(fromEvent(call, 'cancelled')),

Choose a reason for hiding this comment

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

That is the missing feature. Sounds really awesome. Waiting for that feature to be in place. @micmro thanks for that awesome feature.

@kamilmysliwiec
Copy link
Member

Great job @micmro 👍

@lock
Copy link

lock bot commented Sep 24, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Sep 24, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants