Having enabled retries for my Cloud Function, I am wondering what all the cases are that it will retry.
This section seems contradictary to me. Hence, I assume that I do not understand it.
I thought that the following implies that the function that have "Retry on failure" enabled will also retry on fatal errors:
Cloud Functions does not understand a fatal error that shouldn't be retried
However, what is the point of catching errors and using Promise.reject in that case?
I tried to use Promise.reject to cancel retries of my Cloud Function, however, that does not happen.
return Promise.reject(..) // will retry
throw Error() // will retry
Both will retry for a week if the function is not redeployed.
To me it seems like fatal errors and Promise.reject will both retry, however, the documentation says:
you should modify your code accordingly if you support fatal errors
What is the point of this section in the documentation and what should I really do now?
Cloud Functions will retry a function if it yields any sort of error at the end. This includes a rejected promise, a thrown exception, or a timeout.
If you don't want a function to retry, then catch all errors, and return a successful promise. If you know that an error will never go away for a future retry (for example, bad input values), then don't arrange for it to be retried. Otherwise, you will just be charged for all the retries that don't work.
The whole point of retries is to handle cases where there are temporary errors, such as network problems. So, you should make sure that your function only yields an error for cases where it's expected that a function would eventually succeed some time in the future.
Feel free to use the "Send feedback" button on any page of documentation if you find that documentation to be confusing.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With