Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

calling setOptions on subscriber does not take effect #1879

Closed
dermasmid opened this issue Feb 4, 2024 · 5 comments · Fixed by #1954
Closed

calling setOptions on subscriber does not take effect #1879

dermasmid opened this issue Feb 4, 2024 · 5 comments · Fixed by #1954
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.

Comments

@dermasmid
Copy link
Contributor

dermasmid commented Feb 4, 2024

if changing flowControl settings after calling .on they dont not get into effect

const subscription = pubSubClient.subscription(subscriptionNameOrId);
const messageHandler = message => {

  message.ack();
};

subscription.on('message', messageHandler);

// does not have any effect on flow control
subscription.setOptions({
flowControl: {
          maxMessages: 1,
          allowExcessMessages: true,
 }
})

@dermasmid dermasmid added 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. labels Feb 4, 2024
@product-auto-label product-auto-label bot added the api: pubsub Issues related to the googleapis/nodejs-pubsub API. label Feb 4, 2024
@swarmiakimmo
Copy link

I was able to confirm the bug by testing the client with a local script.

@feywind
Copy link
Collaborator

feywind commented Jun 13, 2024

Looks like it's not passing it down to the streaming pull subscriber stream. I'll verify what we want this to do, behaviour-wise.

@theabhinavdas
Copy link

Have the same issue. maxMessages doesn't work for me when using streaming pulls. Any alternative till this is fixed or would we have to do unary pulls?

@theabhinavdas
Copy link

@feywind What's also quite peculiar is that when I use options with subscriptions, it seems to square the number of maxMessages specified. For me, if I set this to 1, it does in fact seem to pull only one message (as noticed in my handler). When I set maxMessages to 2, it seems to pull 4 messages. When I set maxMessages to 3, it seems to pull 9 messages!

const subscription = pubSubClient.subscription(subscriptionNameOrId, {
    flowControl: {
      maxMessages: 1
    }
});

@theabhinavdas
Copy link

@dermasmid from this other issue, it seems setting allowExcessMessages: false in your options fixes the issue like so:

const subscription = pubSubClient.subscription(subscriptionNameOrId, {
    flowControl: {
      maxMessages: 1,
      allowExcessMessages: false
    }
});

It may additionally have something to do with you instantly ack-ing in your messageHandler where you'd expect StreamingPull to pull the next message?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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.
Projects
None yet
4 participants