Why is there no retry config for cloud/firebase functions other than scheduled?

I am enabling retries on most of my 1st gen Firebase functions using 

functions.runWith({ failurePolicy: true}).etc.

Some functions are time-critical and I would only want them to be retried over a short period of time before they should be dropped. Others however are much less time bound, and could still be ok the next day (like sending an email).

I currently use a function to determine if the event should be dropped, but that is only based on the elapsed time and that seems problematic.

If I set the time to 24h, I do not want the retry to happen very often, and the time between retries can be much longer than when I set it to 20mins.

So I would like to configure more things, like exponential backoff (maybe that's the default?), how many retries are being made and what the maximum time is to still be retrying.

It seems that all of these things can be configured for scheduled functions with the retryConfig but looking at the code it does not seem available for other cloud functions like database functions (onWrite, etc) or pubsub topic handlers like pubsub.topic().onPublish()

How come these settings are limited to scheduled functions? Are the settings not relevant when handling pubsub topics?

I had a look at 2nd gen functions and there I also do not see a possibility to configure the retries.

Am I missing something?

Solved Solved
3 1 106
1 ACCEPTED SOLUTION

Hello @0x80,

Welcome to Google Cloud Community!

Take a look at Retry asynchronous functions. The retry function is only available to asynchronous (non-HTTPS) functions. The retry on failure allows 2nd gen functions to retry within a 24-hour window, while 1st gen functions can retry within 7 days. The current retry function's limitation is that it doesn't allow further configuration for the retry.  

Additionally, you can request for a retry configuration by filing a feature request in Firebase. Hope this helps, thank you!

View solution in original post

1 REPLY 1

Hello @0x80,

Welcome to Google Cloud Community!

Take a look at Retry asynchronous functions. The retry function is only available to asynchronous (non-HTTPS) functions. The retry on failure allows 2nd gen functions to retry within a 24-hour window, while 1st gen functions can retry within 7 days. The current retry function's limitation is that it doesn't allow further configuration for the retry.  

Additionally, you can request for a retry configuration by filing a feature request in Firebase. Hope this helps, thank you!