I have a cloud function which is doing a synchronous pull from a pubsub subscription. the request is configured using the returnImmediately flag set to true so that we do not wait for pubsub messages to be present in the queue.
const request = {
subscription: formattedName,
maxMessages: maxMessages,
returnImmediately: true,
};
...
client.pull(request)
...
When there are some messages pending, the request returns very fast ( 100ms ) but when there is no messages in the queue, the call hangs for about 1.5 second before returning the empty array of messages.
as I am in a cloud function, I am not sure asynchronous pull is possible.
how could I get rid of this 1.5 s delay and get the pull(request) returns immediately when there is no pending messages ? it would feel very natural that a synchronous pull() with returnImmediately set to true, returns immediately