-
-
Notifications
You must be signed in to change notification settings - Fork 7.6k
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): grpc client closing #12959
Conversation
Pull Request Test Coverage Report for Build c3aa89dd-6768-4bd8-bcb3-9213772bcb6e
💛 - Coveralls |
.filter(client => client && isFunction(client.close)) | ||
.forEach(client => client.close()); | ||
this.clients.forEach( | ||
client => client && isFunction(client.close) && client.close(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any chance we could keep using filter & forEach combination instead of an inline && condition?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this.clients
is a map, and there is no .filter
Sure, we can convert map to array here, then filter, then foreach over it, but I found this approach too complicated for this functionality
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so instead of using an inline condition could we just use a regular if
statement here? (for better readability)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed
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?
Currently, using GRPC client created through
ClientProxyFactory
, it's not possible to close once initiated connection.That looks like a bug, as
close()
method ofClientGrpcProxy
class trying to call corresponding method not fromClient
instance, created by@grpc/grpc-js
, but from parsed proto package definition, loaded by@grpc/proto-loader
:As a result, network connection to GRPC server never ends, once initiated.
Additionally, connections are not gratefully closing on app termination, using GRPC client via
ClientsModule
, as above described method set forclient.onApplicationShutdown
hook:Issue Number: N/A
What is the new behavior?
public close()
method has been rewritten to properly close the network connection.Does this PR introduce a breaking change?
Other information