nodejs-pubsub icon indicating copy to clipboard operation
nodejs-pubsub copied to clipboard

Message.ack() doesn't work as expected

Open lushu opened this issue 3 years ago • 3 comments
trafficstars

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 avatar Oct 25 '22 23:10 lushu

@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. :)

feywind avatar Nov 09 '22 20:11 feywind

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,

lushu avatar Nov 09 '22 22:11 lushu

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.

feywind avatar Nov 10 '22 18:11 feywind

Closed in favour of https://github.com/googleapis/nodejs-pubsub/issues/1917

feywind avatar May 02 '24 19:05 feywind