Race condition when flushing message queues while a batch is in-flight #951
Labels
api: pubsub
Issues related to the googleapis/nodejs-pubsub API.
priority: p2
Moderately-important priority. Fix may not be included in next release.
type: bug
Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
There seems to be a race condition in
subscriber.close()
(_waitFlush
) when the check for pending requests is made while a batch is currently in-flight.I think we should track the in-flight requests as well, and resolve the
_waitFlush
when in-flight requests have drained.Environment details
@google-cloud/pubsub
version: 1.7.1Steps to reproduce
ack
a messageack
ing (message.ack(): void
),await subscription.close()
Cannot ack messages: Subscription does not exist
I used this test to reproduce the issue, and also tested a potential fix (PR incoming):
The text was updated successfully, but these errors were encountered: