Retry Netlify Function after 15-30 minutes if error in the response

I have a client that has a unique request and was wondering if anyone knows if Netlify may have a solution for this.

I currently wrote a Netlify Function that is hit when a user clicks a button. Inside of that function, it makes an external call to another endpoint (outside of Netlify). The problem is that sometimes this endpoint has issues and is down. So the client would like me to retry it every 15 or 30 minutes or so, for a maximum of three retries.

Does anyone have any idea if Netlify has any kind of ability to handle this? I was thinking maybe I’d have to use background functions to make the calls since the user will most likely close the browser within that time while it’s retrying. If using a background function (which has a 15 min timeout), I’m thinking we set some kind of timer to call the external endpoint after 10 minutes or so within the function, and then if it fails, call the background function again.

Just wondering if anyone has any ideas on how this might be able to be solved. Thanks!

Netlify doesn’t have a built-in feature to handle this. There’s no quick and easy way to solve this on just Netlify. You can definitely use Background Functions if they suit your case.

Thank you for the response @hrishikesh !

Thanks for the explanation @hrishikesh ! Do you know if there is a way to cancel a Background Function? In our case, we’ll call the same Background Function up to three times. But if the call is successful say in the second call, we don’t want to waste resources and were wondering if there would be a way to cancel it at that time. Do you know if there is a way to cancel it if needed?