I have a cloud function that is returning a lot of data (50’000 documents) as objects. When I run it I get the error finished with status: 'response error'
.
This only happens when I export all of the data, when a limit (up to 20’000) is applied it works without problem. This lets me think that the response might be too big, but there is no info in the logs about this at all. Also adding try / catch does not work. In the console I only get the above message without any further indication.
I know that functions normally log when timeout is hit or the memory exceeded, so I am wondering what else could be the source of error.
exports.run = functions.runWith({ timeoutSeconds: 540, memory: '8GB' }).https.onRequest(async (req, res) => { try { const querySnap = await db.collection("myData").get(); const data = querySnap.docs.map(doc => doc.data()); return res.status(200).json({ data: data }).end(); } catch (err) { console.log(err); return res.status(400).end(); } });
EDIT: It is indeed the size of the response that causes this error. You can reproduce this if you simply return data of given size (with Buffer.alloc(bytes)
).
Advertisement
Answer
I thins you hit the max HTTP response size which is 10 MB for HTTP functions
Reference : https://cloud.google.com/functions/quotas#resource_limits with the screenshot below take from that ref.