nodejs-pubsub
nodejs-pubsub copied to clipboard
Message.ack() doesn't work as expected
Problem:
When Message.ack was called and immediately followed by clean up subscription, the ack message actually won't be sent out.
Possible Reason:
The reason is: the Message.ack method calls an async method Subscriber.ack without handling the Promise or returning it. This makes Message.ack quit before the ack message being sent out. Does this make sense?
@lushu Yeah, that makes sense, and I was actually just looking at that code for another question. :) The intention is that those methods are "fire and forget". If exactly once delivery isn't enabled, there won't be a confirmation or failure for the ack.
I hate to call it "as intended", but at the moment, it is. There has been some talk of providing a way for users to explicitly ask for everything to be finished before close() returns, but at the moment, it just drops anything that hasn't sent yet. (Again, unless you are using exactly once delivery, but I wouldn't recommend that just to fix this issue. :)
Thank you @feywind for your explanation. Do you know why this happened only recently? From the git log, it looks like that the ack function has been like this for a long time, but only recently, it couldn't work if followed by a cleaning up. Why in a very long time, it did acknowledge the messages?
Cheers,
We discussed this a bit today, and it sounds like we're intending to cover this case with future updates on close(). I'll reopen this.
Closed in favour of https://github.com/googleapis/nodejs-pubsub/issues/1917