Reputation: 1058
So I have an HTTPS cloud function that has a timeout of 60 minutes.
import { onRequest } from "firebase-functions/v2/https";
export const myFunction = onRequest(
{
timeoutSeconds: 3600,
memory: "4GiB",
maxInstances: 1,
region: "europe-north1",
},
async (req, res) => {
//code that takes up to 60 minutes
});
I want to call this function from a cloud task, but apparently, the maximum timeout for a cloud task is 30 minutes.
import * as tasks from "@google-cloud/tasks";
const task: tasks.protos.google.cloud.tasks.v2.ITask = {
httpRequest: {
httpMethod: 'POST',
url,
body: Buffer.from(JSON.stringify(payload)).toString('base64'),
headers: {
'Content-Type': 'application/json',
},
},
dispatchDeadline: , //<-- this is 30 minutes as far as I understood
scheduleTime: {
seconds: 50
}
Is there a workaround for that?
I wouldn't mind just executing the call without waiting for the response of the cloud function (without waiting for 60 minutes).
But I don't know if that's possible.
Upvotes: 0
Views: 1241
Reputation: 3009
You can set a retry configuration for your tasks, and make your Cloud Function
invocations idempotent (i.e. if a retry comes, but it's for a request that is already processing, don't process it again). Here is a blog post regarding idempotency in Cloud Functions
.
Upvotes: 2