'cloud function triggering delay and retry

I have a firebase trigger function with failurePolicy: true (the function will automatically retry if fails).

I avoid infinite retry loops as described here : https://cloud.google.com/functions/docs/bestpractices/retries#set_an_end_condition_to_avoid_infinite_retry_loops

const eventAge = Date.now() - Date.parse(event.timestamp);
const eventMaxAge = 10000;

// Ignore events that are too old
if (eventAge > eventMaxAge) {
  console.log(`Dropping event ${event} with age ${eventAge} ms.`);
  callback();
  return;
}

I also set the eventMaxAge at 10000ms, but sometimes I get error message with an event age superior > 10000ms on the first processing (not a retry).

Dropping event xxx with age 63210 ms.

That means the function has been first triggered 63s after the event (!) and the function has dropped the event without being processed.

What are the delays for a function to be triggered? How do you handle such case to be certain the event is processed ?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source