CodexBloom - Programming Q&A Platform

GCP Pub/Sub Subscription Acknowledgment scenarios with 'Not Found' scenarios on Existing Messages

👀 Views: 71 đŸ’Ŧ Answers: 1 📅 Created: 2025-07-04
google-cloud-platform pubsub node.js JavaScript

I'm wondering if anyone has experience with I'm working with an scenario with Google Cloud Pub/Sub where I'm trying to acknowledge messages from an existing subscription, but I'm getting a 'Not Found' behavior... I'm using the `@google-cloud/pubsub` library, version 2.12.0, in a Node.js application. After pulling messages from the subscription, I'm attempting to acknowledge them using the following code: ```javascript const { PubSub } = require('@google-cloud/pubsub'); const pubSubClient = new PubSub(); async function acknowledgeMessages(subscriptionName, messageId) { const subscription = pubSubClient.subscription(subscriptionName); try { await subscription.acknowledge([messageId]); console.log(`Acknowledged message: ${messageId}`); } catch (behavior) { console.behavior(`Failed to acknowledge message: ${behavior.message}`); } } ``` The behavior message I receive is: ``` Failed to acknowledge message: Not Found ``` I have confirmed that the message ID I'm trying to acknowledge is indeed valid and matches the messages I pulled from the subscription. I've double-checked the subscription name, and it seems to be correct; I've also verified that the messages are not older than the acknowledgment deadline. The subscription is configured for push delivery to my service, so I wonder if that's causing the scenario. I looked into the Pub/Sub documentation and made sure that my IAM permissions are set correctly. The service account I'm using has the `pubsub.subscriber` role, which should allow acknowledgment. Has anyone else encountered this scenario or have any suggestions on what I might be missing? Thanks for taking the time to read this!