Reputation: 2321
I´m trying to use a setInterval inside a firebase function to run for 40 minutes then stop. Since the max timeout for onCall function is 9 minutes what workaround could be used?
I saw a suggestion to use GCP tasks but didn´t was able to find how I could make use of it in this context
Even if I would need to run a timeout to run 40 minutes later, how this could be done with GCP tasks?
Upvotes: 1
Views: 536
Reputation: 2048
For this case an option is to create a HTTP Target task and put it in a task queue. Basically, you will schedule something to call your Cloud Function when you want. There is no way to keep the function alive for more than 9 minutes, but, instead of that, Cloud Tasks would call it again and again when you want. Here you can find the official documentation guide of achieving that. Keep in mind that, as it is stated in the official documentation:
Timeouts: for all HTTP Target task handlers the default timeout is 10 minutes, with a maximum of 30 minutes.
Honestly, for your use case, my recommendation would be to use forget about Cloud Functions and think more of using App Engine or Cloud Run. I think they would be more suitable.
Upvotes: 1