Nodejs-pubsub: Publisher Client `close()` method

Created on 12 Nov 2019  路  8Comments  路  Source: googleapis/nodejs-pubsub

Is your feature request related to a problem? Please describe.

There's currently no method to close a client. I'm using the client in a persistent environment, which isn't guaranteed to be actively processing data at any given time.

If there's a delay between messages, there's a chance that the network connection fails to resolve, eg. if the connection is closed on the server side but not client side.

In order to cover this, I need to open a new connection and I have no way to close the stale one, so basically this eventually leads to a proliferation of open but unused sockets.

Describe the solution you'd like

A client.close() method which allows me to terminate a client connection client-side.

Describe alternatives you've considered

Manually closing sockets or terminating the entire environment every time we hit a stale connection are the only real options I can see - neither are desirable for obvious reasons.

pubsub feature request

Most helpful comment

@merlinnot just added to the schedule for our next library group meeting; @feywind probably worth having this on your radar 馃憤

All 8 comments

This is a great feature request, I'd benefit from it too.

There's a similar FR against Firestore: https://github.com/googleapis/nodejs-firestore/issues/769
And a preliminary PR against API Client Generator for TypeScript: https://github.com/googleapis/gapic-generator-typescript/pull/126

@bcoe @callmehiphop It was now implemented in the Firestore client and I got impressive gains thanks to it, see https://github.com/googleapis/nodejs-firestore/issues/769#issuecomment-568165126. Is there a chance to prioritize this feature somehow? I have the exact same issue with PubSub, as I had with Firestore.

@merlinnot just added to the schedule for our next library group meeting; @feywind probably worth having this on your radar 馃憤

Good to hear this will be discussed!

For the record/in case it's pertinent I read over the issue @merlinnot linked to for firestore, and we face exactly the same problem (although he described it better than I!)

@bcoe Did the meeting happen already?

@merlinnot @colmsnowplow It's been discussed a couple of times. I haven't heard a super definite "yay do it", but I think the consensus is that we're planning to do it. Basically that it probably shouldn't be necessary to use a close() method, but that it will still probably help people for now. It's behind another fire or two though :)

@feywind Some edge cases were discussed in this thread: https://github.com/grpc/grpc-node/pull/1083. It's quite lengthy, but it took quite some time to get to a common understanding. Bottom line: there are some scenarios where having a close method is strictly necessary and there's no way around it. That's why a patch was made to @grpc/grpc-js, then googleapis/gapic-generator-typescript and then googleapis/nodejs-firestore.

While I do acknowledge and understand that this is not necessary in _most_ of the scenarios, power users do and will always require it for more advanced scenarios.

Potentially related: https://github.com/googleapis/nodejs-pubsub/issues/725

(for the subscriber side)

Was this page helpful?
0 / 5 - 0 ratings