nodejs-pubsub
nodejs-pubsub copied to clipboard
message.ack() not working in the 3.2.x releases
(This seems related to the previous issues #1653 and #1648)
We've been using this package with no issues (and no code changes) on our side up to version 3.0.1. After upgrading to version 3.2.0 or 3.2.1 message acknowledgements are silently being ignored. It's quite an insidious bug, since the behavior of message.ack()
is supposed to be unchanged (we're not using exactly-once delivery), and since it's a void function it's not really possible to see that the behavior has actually changed.
If this was intended, it should be a major version upgrade, IMHO, since it breaks existing code.
Environment details
- OS: Ubuntu(?) (Google Cloud Functions v1)
- Node.js version: 16
- npm version: N/A
-
@google-cloud/pubsub
version: 3.2.0, 3.2.1
Steps to reproduce
- Create a topic and a subscription
- Insert at least 5 messages
- Use the following code (or similar) to ack() them:
import { Message, PubSub } from "@google-cloud/pubsub";
let messageCount = 0;
const pubSubClient = new PubSub();
const subscription = pubSubClient.subscription(SUBSCRIPTION_NAME);
subscription.on("message", messageHandler);
function messageHandler(message: Message): void {
messageCount += 1;
// Do something with the message
message.ack();
if (messageCount > 5) {
subscription.removeListener("message", messageHandler);
}
}
The above works as expected (i.e. the messages get acknowledged) using 3.0.1, but it fails (messages remain on the topic, don't get acknowledged) using 3.2.0 and 3.2.1