Firebase Cloud Function: Retry behaviour and backoff times

58 views Asked by At

I do not fully understand retry behavior. I have set up cloud functions to retry on failure (checked in console, done via cli) They are idempotent and have a lease and drop off mechanism if tried to many times or to frequently. But my functions are not retried on error.

According to the documentation a rejected promise will get retried. So my code looks something like this:

try{
 if(should process()){
   await process()
}catch(err){
  //Log error
  Promise.reject("Retry")
}

The documentation has this code:

return doFooAsync().catch((err) => {
if (isFatal(err)) {
    console.error(`Fatal error ${err}`);
}
return Promise.reject(err);
});

This shows an example how to deal with exceptions. I do not understand this. Should the if not return a resolved Promise to prevent fatal errors from getting retried? As the rejected Promise will lead to a retry?

I guess not as my functions with similar code are not getting retried. What do I have to change for retry to work?

Second: What are the retry windows? I cannot find any backoff times? My functions are blocked from retry for 60s. If a retry occurs before after the previous failed, it will fail again until 10 failures occured. After the event will get dropped. So I need to know backoff times at least roughly to determine if my logic works. Any idea where to find this?

0

There are 0 answers