p3sn
p3sn

Reputation: 1072

Retry Cloud Functions for Firebase until it succeeds

I'd like to create a cloud function which sends an e-mail based on a change in my database. I use postmark, but that's not relevant for this function. I looked at the firebase-examples.

My question is: What if the mail service returns an error or if the mail service is temporary down? I don't see any form of error handling in the examples.

My 'solution' would be to try again in 5 minutes for example. Is that possible and advisable in cloud functions?

Upvotes: 1

Views: 2353

Answers (1)

Günter Zöchbauer
Günter Zöchbauer

Reputation: 657058

If you throw an exception when sending the email fails, it should retry the function up to 7 days.

Open detailed usage states for your function in the firebase console

enter image description here

Edit the function

enter image description here

Click the link to configure retry

enter image description here

Enable "Retry on failure"

enter image description here

I haven't tried it myself yet for your use case, but it works for my storage triggered function when it fails.

Upvotes: 2

Related Questions