Function gets executed without errors. I am getting the status
Function execution took 60004 ms, finished with status: 'timeout'
I am not sure what the issue is. Everything in my function looks good to me. I also noticed functions sometimes take several seconds to update database and sometimes it is instantly. Is it normal that execution times varies from instantly to couple second? Should execution times be instantly?
exports.countproposals = functions.database.ref("/proposals/{jobid}/{propid}").onWrite((event) => {
const jobid = event.params.jobid;
const userId = event.params.propid;
const userRef = admin.database().ref(`users/${userId}/proposals/sent`);
if (event.data.exists() && !event.data.previous.exists()) {
userRef.child(jobid).set({
timestamp: admin.database.ServerValue.TIMESTAMP
});
} else if (!event.data.exists() && event.data.previous.exists()) {
userRef.child(jobid).remove();
}
const collectionRef = admin.database().ref(`/jobs/${jobid}`);
const countRef = collectionRef.child("proposals");
return countRef.transaction(current => {
if (event.data.exists() && !event.data.previous.exists()) {
return (current || 0) + 1;
} else if (!event.data.exists() && event.data.previous.exists()) {
return (current || 0) - 1;
}
});
});
Function execution time is limited by the timeout duration, which you can specify when you deploy a function. By default, a function times out after one minute (60 seconds), but you can extend this period: In Cloud Functions (1st gen), the maximum timeout duration is nine minutes (540 seconds).
Time Limits60 minutes for HTTP functions. 10 minutes for event-driven functions.
By default each Cloud Run container instance can receive up to 80 requests at the same time; you can increase this to a maximum of 1000.
From my experience I would guess that this is (hopefully) a temporary problem with firebase function itself. I get the same warnings/error for a function which yesterday took ~200 milliseconds to execute in average.
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