Title: Need to start batch processing in firebase functions after API call
Tags: node.js;firebase;firebase-realtime-database;google-cloud-firestore;batch-processing
Question: I have written a firebase function API call.
Now, when I call this API it should return a response as {status: 200, message: 'In progress'} and batch processing should start at the server end.
But after processing a few records I receive an error
Function execution took 60002 ms, finished with status: 'timeout'
Need to process more than 100+ records.
Currently, my code looks like
app.post('/writeBatchData', async (req, res) =&gt; {
writeBatchData(req.body);
res.json({
status: 200,
message: 'In Progress'
const writeBatchData = async recordDetails =&gt; {
for (let count = 0; count < recordDetails.length; count++) {
let recordInformation = recordDetails[count];
const recordInfo = await writeDataOnDatabase(recordInformation);
// db operation
}
return 'success';
async function writeDataOnDatabase(recordInfo) {
try {
// write data on database
catch(error) {
What is the correct way to do this??
Thanks In Advance
Comment: Hello, you need to add to your question the **entire** code of your function (I guess it is an HTTPS Cloud Function).

Comment: Please check the code above


Here is another answer: The issue here was by default the timeout for firebase is one minute for both frontend and backend service; So whatever the number of records processed in one minute is processed
Currently, the workaround I have used is I have increased the timeout to 540 seconds i.e 9 minutes (which is max in firebase). So I am able to process more records.
But this is not the final solution
So if anyone is having a better solution, please comment

{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 1, 'CommentCount': 2, 'ContentLicense': 'CC BY-SA 4.0', 'CreationDate': '2019:00:12/04/19', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<node.js><firebase><firebase-realtime-database><google-cloud-firestore><batch-processing>', 'Title': 'Need to start batch processing in firebase functions after API call', 'ViewCount': 260, 'id': 59181787, 'user_AboutMe': None, 'user_AccountId': 12339868.0, 'user_DisplayName': 'Muddassar Shaikh', 'user_Reputation': 21.0, 'user_Views': 3.0, 'user_id': 10557238.0}}